Functions
A function works out a value while your model runs. You call one by name inside any expression or action-logic statement, and it hands back a number or a piece of text: the current clock time, how many entities are in an activity, the free units of a resource, an entity’s cost so far.
A statement does something and sits on its own line. A function returns a value and goes wherever a value is allowed: the right-hand side of an assignment, a processing time, a route or gate condition, an arrival quantity.
The seven families
Section titled “The seven families”Functions are grouped by what they read. Use this to find the right page fast:
| Family | What it reads | Reach for it when |
|---|---|---|
| System Values | The run as a whole: the clock, work in process, entity counts, random draws | You need the time of day, the size of the backlog, or a random number |
| Activity Queries | The state of one activity: contents, capacity, queue length, throughput, whether it is blocked | You are routing around a bottleneck or holding work back until there is room |
| Resource Queries | The state of one resource: free units, utilization, shift, units down | You are choosing between people or machines, or waiting for one to come free |
| Entity Properties | Values carried by the entity being processed: age, cost, type, time so far | You are branching on what this particular entity is, or how long it has waited |
| Gate, Signal, and Inventory Queries | Whether a gate is open, a signal is on, or how much stock is on hand, on order, and worth | You are coordinating one part of the model with another |
| Math Functions | Nothing in the model; they work on the numbers you give them | You need to round, cap, or otherwise tidy a calculated value |
| String Functions | Nothing in the model; they work on the text you give them | You are building an entity name or comparing a text attribute |
Calling a function
Section titled “Calling a function”Type the function wherever a value is allowed. Object queries name the object in double quotes, for example Resource("Doctor").FreeUnits or Activity("Inspect").Contents. Math and string functions take their arguments in parentheses instead, and system values such as CLOCK need no argument at all.
As you type in the editor, ProcessModel suggests the function, shows what it returns, and lists its parameters, so you rarely have to remember the exact form.
// A query names its object in double quotes, then the value you wantSET v_Free TO Resource("Doctor").FreeUnits
// A math or string function takes its arguments in parenthesesSET a_Price TO ROUND(a_Raw * 1.08, 2)
// A system value needs nothing at allSET a_StartTime TO CLOCKNotes in action logic start with //, as above. An apostrophe is not a comment marker, so write notes with // and names with double quotes. See Comments.
Two functions that live here
Section titled “Two functions that live here”Two small functions do not fit a family and are documented on this page:
| Function | What it returns |
|---|---|
IF(condition, valueIfTrue, valueIfFalse) | One of two values, depending on a test. |
PERCENT(p) | True p percent of the time, for a quick random split. |
// Inline IF returns a value, so it fits where only one value is allowed// A rush job is allowed 2 minutes, everything else 10SET a_Allowed TO IF(a_Priority = 1, 2, 10)
// PERCENT is true p percent of the time: a quick 30 to 70 splitSET a_Branch TO IF(PERCENT(30), 1, 0)Do not confuse the inline IF(…) function here with the IF … THEN … ENDIF statement on the Flow Control page. The function returns a value; the statement runs different lines.
A worked example
Section titled “A worked example”Four families in one activity. A claim arrives, and the logic works out how long it will take, waits for someone to do it, and decides where it goes next:
// Entity property: is this a rush claimSET a_Rush TO IF(Entity.TypeName = "Rush", 1, 0)
// Math function: hold the handling time between 1 and 20 minutesSET a_Handle TO CLAMP(a_BaseTime * a_Complexity, 1, 20)
// Rush claims are given a quarter off that timeIF a_Rush = 1 THEN SET a_Handle TO a_Handle * 0.75 ENDIF
// Resource query: wait for an assessor, then spend the timeWAIT UNTIL Resource("Assessor").FreeUnits > 0TIME a_Handle min
// Activity query: send it to whichever review desk is emptierIF Activity("Review1").Contents < Activity("Review2").Contents THEN ROUTE 1 ELSE ROUTE 2 ENDIFLegacyHow this worked in the previous version
Functions provide you with critical system information at any given time during the simulation. They can be used in an assignment statement to set the value of a variable or attribute or in an IF…THEN statement to make a decision based on system information. There are several system functions:
System reserved words cannot be used as variable names, attributes, or scenario parameters.

