If - Else If - Else - EndIf
if expression then
…
else if expression then
…
else
…
endif
These statements allow conditional execution of FISH code segments; else and else if are optional, and the word then may be omitted if desired.
The expression following if or else if may be any expression that evaluates to a boolean, or has a type that will convert to a boolean after evaluation. For example, an integer result will be considered false if it is 0 and true if it has any non-zero value.
if … else if … else … endif clauses can be nested to any depth.
As a special case shorthand, a FISH expression or function list may follow the then keyword in the following syntax
if expression then expression
This allows simple conditions to be expressed in a single line, for example:
if x<0.0 then system.error = "this is an error"
If the shorthand syntax is used else and else if statements are not allowed, and the then keyword is required.
Was this helpful? ... | Itasca Software © 2024, Itasca | Updated: Sep 26, 2024 |