Flow Control
Flow-control statements decide which lines of logic run.
Branching
Section titled “Branching”IF a_Priority = 1 THEN GET 1, ExpertELSEIF a_Priority = 2 THEN GET 1, SeniorELSE GET 1, ClerkENDIFAn IF … THEN block, with optional ELSEIF and ELSE, is closed by ENDIF. Blocks can be nested.
Looping
Section titled “Looping”WHILE v_Tries < 3 INC v_TriesLOOPWHILE … LOOP repeats while its condition holds. REPEAT … ENDREPEAT and FOR i = 1 TO n … NEXT are also available, and EXIT breaks out of a loop early.
Define a label with a leading colon and jump to it with GOTO. RETURN stops the rest of the logic block immediately:
IF a_Ready = 0 THEN RETURN ENDIFLegacyHow this worked in the previous version
The if statement is used to test for a condition and then execute sections of logic based on whether that condition is True or False. The condition is described with a Boolean expression , If the condition is True, the logic flow branches one way. If the condition is False, the flow branches in another direction.
If-Then statements can be added to Action Logic fields of the following objects:
- Arrivals
- Activities
- Storages
- Routings
Syntax
Section titled “Syntax”SWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCXsKCVN0YXRlbWVudAoJfQ==SWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCXsKCVN0YXRlbWVudDEKCX0KRWxzZQoJewoJU3RhdGVtZW50MgoJfQ==SWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCXsKCVN0YXRlbWVudDEKCVN0YXRlbWVudDIKCX0KRWxzZQoJewoJU3RhdGVtZW50MwoJU3RhdGVtZW50NAoJfQoKSWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCXsKCVN0YXRlbWVudAoJfQoKSWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCXsKCVN0YXRlbWVudDEKCX0KRWxzZQoJewoJU3RhdGVtZW50MgoJfQ==SWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCXsKCVN0YXRlbWVudDEKCX0KRWxzZQoJewoJSWYgQm9vbGVhbiBFeHByZXNzaW9uIFRoZW4KCQl7CgkJU3RhdGVtZW50CgkJfQoJfQ==
conditional expression Is a comparative expression using comparison operators like the equals sign (=) and the less than/greater than symbols (< >). The result of this expression is either true or false (yes or no). Multiple or alternative conditions can be tested using the operators **AND **and OR. Parentheses may be used for nesting expressions.
**statement_1 **This statement is executed if the conditional expression is true. This can also be a block of statements started with a BEGIN keyword or symbol ({ ) and ended with the **END **keyword or symbol ( }).
statement_2 This statement, preceded by the keyword ELSE, is executed if the conditional expression is false. This can also be a block of statements started with a BEGIN keyword or symbol ({ ) and ended with the END keyword or symbol ( }).
Rules
All words must have at least one space separation
- **NO **IfName = Rework **YES **If Name=Rework **OR **If Name = Rework
- If more than one action is the result of the If-Then statement, the group of statements must be bracketed By the Begin and End statements or {…}
- If Name = Phone_Call Then
- {Inc v_Calls
- Time(5 min)}
- Else
- {Inc v_Fax
- Time(10 min)}In the Example above if the Attribute “name” contains the word Phone_Call, then the statement is true. the statements after the THEN will be executed and all the statements after the Else will be skipped.
- Indenting and carriage returns are optional - but if you want to be able to read your work next week, group blocks of statements and indent so that it is easy to see the result of true or false conditions.
Example
In the following examples the IF…THEN…ELSE statement is used to make decisions about what happens in the model. In the first example, the variable v_Calls is incremented if the Name has the same descriptor value as Phone_Call. The second example shows a decision made based on the a_Patient_Type. If the patient is critical, both a Nurse and a Doctor resource are needed. Otherwise, only a nurse is captured and the activity takes less time.
SUYgTmFtZSA9IFBob25lX0NhbGwgVEhFTiBJTkMgdl9DYWxscw==
SUYgYV9QYXRpZW50X1R5cGUgPSBDcml0aWNhbCBUSEVOCnsKCUdFVCBOdXJzZSBBTkQgRG9jdG9yCglUSU1FKE4oMzAsIDUpIG1pbikKCUZSRUUgQUxMCgl9CkVMU0UKCXsKCUdFVCBOdXJzZQoJVElNRShOKDgsIDEpIG1pbikKCUZSRUUgQUxMCgl9
- Comments
- ( ) = ( ) assignment
- ANIMATE
- DEC
- DISPLAY
- FREE
- GET
- INC
- IF…THEN…ELSE
- JOINTLYGET
- NEWGRAPHIC
- NEWNAME
- PAUSE
- REPORT
- STOP
- TIME
- WAIT UNTIL
- WHILE…DO
WHILE DO statement
Section titled “WHILE DO statement”Repeats logic or logic block continuously while a condition remains true.
Syntax
Section titled “Syntax”V0hJTEUgRE8KV0hJTEUgdl9WYXIxID4gMyBETyBUSU1FKDEwIG1pbikKV0hJTEUgdl9WYXIxIDwgYV9BdHRyMyBBTkQgVmFyMiA+PSA1IERPCnsK4oCmCn0=
Boolean expression The condition that must be satisfied to continue processing the entity or resource. One side of the Boolean expression must contain a variable that can change due to some other event in the model.
Example
The following example uses the WHILE…DO loop to track the day of the week. v_Var1 is a variable that is set to zero at the beginning of the simulation and remains constant, so the loop will continue for the length of the simulation. v_Day_of_Week is a variable that changes every 24 hours and is reset to one on the eight day.
V2hpbGUgdl9WYXIxID0gMCBETwp7CklOQyB2X0RheV9vZl9XZWVrCklGIHZfRGF5X29mX1dlZWsgPSA4IFRIRU4gdl9EYXlfb2ZfV2VlayA9IDEKVElNRSgyNCBIcikKfQ==

