&cond - Conditional expression operator
&cond log expr1 expr2
The conditional expression &cond provides an alternative way to write !if-!else-!endif constructs, e.g.:-
!if &gre %a %b set-variable %z %a !else set-variable %z %b !endif
may be replaced with a conditional expression, breaking down the components then
log is &gre %a %b
expr1 is %a
expr2 is %b
rewriting the expression we get:
set-variable %z &cond &gre %a %b %a %b
This is far more concise, albeit a little less readable, but does improve the performance of macros as there is less information to interpret.
The &cond operator accepts three fields, ALL fields are evaluated although only one of the results expr1 or expr2 is used. The log field is a logical value, if it is non-zero (TRUE) then the result of the expr1 evaluation is used, otherwise the result of expr2 is used.
It should be noted that the conditional expression may be used in any construct i.e. &add(4), &cat(4), etc. the expr arguments may be strings, numbers or booleans the resultant value of the expr arguments is simply returned to the calling expression.
Copyright (c) 1998-2006 JASSPA
Last Modified: 2002/01/11
Generated On: 2006/10/07