Skip to content

Resource Queries

Resource queries read the state of a resource. Name the resource in quotes.

QueryWhat it returns
Resource("X").FreeUnitsUnits currently free.
Resource("X").Available1 if any unit is free, 0 if none.
Resource("X").UtilizationFraction of time in use, from 0 to 1.
Resource("X").OnShift1 if the resource is on shift, 0 if off.
Resource("X").QtyUnits of the resource the current entity holds.
Resource("X").WaitCountEntities waiting for the resource.
Resource("X").DownQtyUnits currently down.

Each line below is a complete piece of action logic, with a // note saying what it does.

Whether anyone is free, and how many:

// Hold the entity here until a doctor comes free
WAIT UNTIL Resource("Doctor").FreeUnits > 0
// Take the shortcut only when a specialist is free; Available is 1 or 0
IF Resource("Specialist").Available = 1 THEN GET 1, Specialist ENDIF

How hard the resource is working, and whether it is on duty at all:

// Share of the run the doctors have been in use, from 0 to 1
SET v_DoctorUse TO Resource("Doctor").Utilization
// Send work to the night desk only while its clerk is on shift
IF Resource("NightClerk").OnShift = 1 THEN ROUTE 1 ELSE ROUTE 2 ENDIF
// Note when a machine has units down for repair
IF Resource("Machine").DownQty > 0 THEN DISPLAY "A machine unit is down" ENDIF

What this entity holds, and who else is waiting:

// Units of Nurse this entity is holding right now
SET a_NursesHeld TO Resource("Nurse").Qty
// Call for a second window when the queue for the teller grows
IF Resource("Teller").WaitCount > 5 THEN SIGNAL SEND "OpenWindow" ENDIF
LegacyHow this worked in the previous version

Returns the free units of an activity or resource (an integer).

Example

The example below demonstrates the use of the FREEUNITS() function to adjust the processing time for an entity based on the number of units of a resource available to process it. Once a Plane arrives at a passenger gate, it captures a certain number of resources named BH (Baggage Handlers). Operation logic at the gate determines how many BH resources have been captured and, accordingly, how long it will take to service the Plane. The more Baggage Handlers a Plane captures, the less time it takes to service it.

V0hJTEUgRlJFRVVOSVRTKEJIKSA8MwoJewoJRE8gVElNRSgyIG1pbikKCX0KSUYgRlJFRVVOSVRTKEJIKT49NSBUSEVOIHtHRVQgNSBCSH0KRUxTRQoJewoJR0VUIEZSRUVVTklUUyhCSCkgQkgKCVRJTUUoNjAvUkVTUVRZKEJIKSBtaW4pCgl9

Returns the number of units of a specific resource that the current entity owns. You can use RESQTY() to determine the amount of time necessary to process an entity based on the number of units of a resource the entity owns.

Example

The example below demonstrates the use of RESQTY() to adjust the processing time for an entity based on the number of resources available to process it. Once a Plane arrives at a passenger gate, it captures a certain number of resources named BH (Baggage Handlers). Operation logic at the gate determines how many BH resources have been captured and, accordingly, how long it will take to service the Plane. The more Baggage Handlers a Plane captures, the less time it takes to service it.

SUYgRlJFRVVOSVRTKEJIKT49NSBUSEVOIHtHRVQgNSBCSH0KRUxTRQoJewoJR0VUIEZSRUVVTklUUyhCSCkgQkgKCX0KVElNRSg0NS9SRVNRVFkoQkgpIG1pbik=

The percent function allows you to execute one or more statements only a certain percentage of the time. Used in an IF…THEN statement, the function returns a TRUE or FALSE.

To use the percent function, enter PERCENT(n) where n is the percentage of the time that the statement will return a TRUE condition in an IF…THEN statement.

Example

In the first example, logic following the THEN statement is executed 21.5% of the time. In the second, logic following the THEN statement is executed 35% of the time and the logic following the ELSE statement is executed 65% of the time.

MSkgSUYgUEVSQ0VOVCgyMS41KSBUSEVO4oCmCjIpIElGIFBFUkNFTlQoMzUpIFRIRU7igKYKRUxTReKApg==