Program Flow- (Built-in Functions)
Expression Syntax: Choose(index, choice-|0, , , , )
index
Numeric expression which evaluates to a number between 1 and the number of available choices.
a, b, c, d,... [choice-1], [choice-2], [...], [choice-n]
The list of choice values [choice-1], [choice-2], [...], [choice-n]. The values may be strings or numbers, but must all be of the same type.
Returns:
The value at the given index. If index evaluates to 1 then the value "a" is returned.
Note: All choice values, "a", "b", etc., will be evaluated, even though only one of them will be returned. Therefore, all of them must be valid expressions.
Example:
Choose(Status&,"Pending","Approved","Closed")
will return "Pending" if the value of the user attribute "Status&" on the current expression item equals 1, "Approved" if "Status&" equals 2, etc.
Expression Syntax: Iif(expression, truepart, falsepart)
expression: An expression which evaluates to True or False, for example _length#>1000.
truepart: A regular expression which is returned when the Boolean test expression is True.
falsepart: A regular expression which is returned when the Boolean test expression is False.
-
If the expression is True the value truepart is returned.
-
If the expression is False the value falsepart is returned.
Example:
Iif(_length#>1000,"This Line is long", "This Line is short")
returns the string This Line is long if the _length# geometry system property exceeds 1000 dataset units. Otherwise the string This Line is short will be returned.
Note: Both truepart and falsepart will be evaluated, even though only one of them will be returned. Therefore, both of them must be valid expressions. In the case of a non-Boolean expression, the Switch function must be used.
Expression Syntax: Switch (expression,key1,value1,key2,value2 ,…,no matches found)
If expression is equal to key1 then the result is value1
If expression is equal to key2 then the result is value2 .... and so on with more key/value pairs.
If there are no matches the result is no matches found.
Examples:
Switch(expression&, 25,100, 50, 200, 75, 300, 1000)
- If the content of expression& is 50 then 200 will be returned.
- If the content of expression& is not 25, 50 or 75 then the number 1000 will be returned.
Switch(Purchase$, key1$,value1$,key2$,value2$,key3$,value3$,default$)
-
If the content of Purchase$ contains the same text as key1$ then the content of value1$ will be returned, if the content of Purchase$ is the same text as key2$ then the content of value2$ will be returned, etc.
-
If the content of Purchase$ is not the same as any of the text contained in key1$, key2$, etc. then the content of default$ will be returned.