-
Notifications
You must be signed in to change notification settings - Fork 0
advflowctl
Serra Royale edited this page Nov 22, 2023
·
1 revision
Provide advanced flow-control statements similar to other programming languages.
Enabled by: yoption advflowctl;
Keywords:
break
case
constant
continue
switch
...
:
&&&
|||'break' : valid in 'do', 'for', 'foreach', 'switch', 'while' 'continue' : valid in 'do', 'for', 'foreach', 'while'
'&&&' : provides short-circuiting AND operation
left-hand operand evaluated before right-hand operand
right-hand operand evaluated only if left-hand operand is true
'|||' : provides short-circuiting OR operation
left-hand operand evaluated before right-hand operand
right-hand operand evaluated only if left-hand operand is false
'constant' usage as follows:
'constant' name '=' constantexpr ';'
constantexpr := floatconstant | integerconstant | stringconstant | constantexpr constbinop constantexpr | constunop constantexpr
constbinop := '+' | '-' | '*' | '/' | '%' | '&' | '|' | '^'
constunop := '-' | '~' name is defined to be the same type as constantexpr
Note: & | ^ ~ require all integer operands
- * / % require either integer or float operands
only + is valid for strings'switch' usage as follows :
'switch' '(' integerexpression ')' '{'
[ 'case' integerconstantexpression [ '...' integerconstantexpression ']' ':' singlestatement ]*
[ 'default' ':' singlestatement ]
'}'the switch statement is also valid for string expressions, for example:
switch (command) {
case "turnleft": {
TurnLeft ();
break;
}
case "turnright": {
TurnRight ();
break;
}
default: llOwnerSay ("dont know how to handle " + command);
}