Syntax of The Scripting Language
IF...ELSE...ENDIF:
IF (Condition)
:
ENDIF
Or…
IF (Condition)
:
ELSE
:
ENDIF
Note that between the "IF" and "(Condition)" there MUST be a blank. Do not place commands on the same line as the IF statement, but only on new lines.
"Condition" can be any expression returning TRUE or FALSE, e.g. "IF (Weight>10)"
The lines below the IF statement until ENDIF or ELSE are the commands to be executed if "Condition" evaluates to TRUE.
Examples:
IF (Amount*1.16>800)
OKBox('Warning: Amount including VAT is larger than 800')
ENDIF
IF (YesNoBox('Print report now?'))
RETURN(TRUE)
ELSE
RETURN(FALSE)
ENDIF
LOOP...ENDLOOP
LOOP
:
ENDLOOP
You can place expression commands between LOOP and ENDLOOP, and when reaching the ENDLOOP statement the script will start again at the line below LOOP. You can exit the loop only by using the BREAK or BREAKLOOP commands (see below).
Example:
SetVar('Temp',1);
LOOP
SetVar('Temp',GetVar('Temp')+1);
IF (GetVar('Temp')>10)
BREAKLOOP
ENDIF
ENDLOOP
BREAK
BREAK has no parameters, it just exits from the current IF or LOOP block instantly, continuing with the commands following the ENDIF or ENDLOOP statement. Note that in the above example break would only exit from the IF statement, not from the loop.
BREAKLOOP
This is the same as BREAK, only that it exits from the current loop no matter if BREAKLOOP is used from within one or more IF blocks.
EXIT
EXIT has no parameters. It just completely exits the script execution instantly.
RETURN
Or…
RETURN(Expression)
RETURN sets the current scripts result (a result is needed for the BeforePrint event: TRUE to confirm printing of the current band, FALSE to skip printing the band). "Expression" must evaluate to TRUE or FALSE.
Example:
RETURN(FALSE)
RETURN(Weight>10)
The second example would only print the band if the WEIGHT datafield value is greater than 10.