2.8 KiB
CONDITION
An object that describes a comparison of two operands. Configured by three fields in the script and invoked through CHECK or one of the control-flow methods (BREAK, ONE_BREAK).
Fields
OPERAND1
STRING OPERAND1
The left-hand operand of the comparison. The field holds the operand's textual form, which is parsed on every evaluation. Accepted forms:
- a quoted string literal (
"..."or'...'), - a boolean literal (
TRUE,FALSE), - a numeric literal (
5,-3.14), - a variable name (its value is fetched; for variables of type
EXPRESSION,CONDITION, orCOMPLEXCONDITION, the variable is recursively evaluated), - a script fragment — text starting with
[,*, or containing the^or|operators.
OPERAND2
STRING OPERAND2
The right-hand operand of the comparison. The interpretation rules are identical to those of OPERAND1.
OPERATOR
STRING OPERATOR
The comparison operator. Defaults to EQUAL. Accepted values:
| Value | Meaning |
|---|---|
EQUAL |
equal to |
NOTEQUAL |
not equal to |
LESS |
less than |
GREATER |
greater than |
LESSEQUAL |
less than or equal |
GREATEREQUAL |
greater than or equal |
Methods
BREAK
void BREAK([BOOL emitSignals])
Evaluates the condition. If the result is TRUE, aborts the entire current call tree (the same effect as @BREAK). If the result is FALSE, the method has no effect.
Parameters
emitSignals— (optional) ifTRUE, also firesONRUNTIMESUCCESSorONRUNTIMEFAILEDdepending on the result. Defaults toFALSE.
Examples
COND1^BREAK(TRUE);
CONDKONTROLA^BREAK(TRUE);
CHECK
BOOL CHECK([BOOL emitSignals])
Evaluates the condition and returns the comparison result.
Parameters
emitSignals— (optional) ifTRUE, also firesONRUNTIMESUCCESSorONRUNTIMEFAILEDdepending on the result. Defaults toFALSE.
Returns: BOOL — the comparison result.
Examples
CONPR1^CHECK(TRUE);
CONPR2^CHECK(TRUE);
ONE_BREAK
void ONE_BREAK([BOOL emitSignals])
Evaluates the condition. If the result is TRUE, aborts only the current procedure (the same effect as @ONEBREAK). If the result is FALSE, the method has no effect.
Parameters
emitSignals— (optional) same as forBREAK.
Examples
COND1^ONE_BREAK(TRUE);
CONDREMOVEMENUITEM^ONE_BREAK(TRUE);
Signals
ONRUNTIMESUCCESS
Fired when the condition evaluated to TRUE and emitSignals was TRUE.
ONRUNTIMEFAILED
Fired when the condition evaluated to FALSE and emitSignals was TRUE.