GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Four — Flow Control (continued)
4.8 ‘if’, ‘elseif’ and ‘else’ Statements
The if statement processes a single expression and then acts depending the on boolean result of that process. The expression can be simple or extremely complex, but in the end, must resolve to logical FALSE or TRUE. For example:
if (a == b) {
...
}
if (response != "YES") {
...
}
if ((a == b) && (b == c)) {
...
}
If the result is nonzero (TRUE), the statement or block of statements following the if statement will be executed. If the result is zero (FALSE), the statement or block of statements is skipped. In addition, an else conditional can be added to execute a statement or block of statements if the boolean expression results in a FALSE condition.
The elseif statement allows a series of conditions to be in the form of a cascade:
if (response == "YES") {
...
}
elseif (response == "NO") {
...
}
elseif (response == "CANCEL") {
...
}
else {
...
}
Unlike the first example, this comprises an interconnected set of conditions. If the response is false, the next elseif condition is tested and so on. An optional end else can be added for the end catch all.
The if, elseif and else statements use the following formal syntax:
if (expression) {
statement(s)
}
[elseif (expression) {]
[statement(s)]
}
[else]
[statement(s)]
}
Zero or more elseif statements can be added, but the elseif must be associated with a preceding if block. The else statement is optional and when omitted, program execution will continue after the block if the expression is not true. The elseif and else statements must immediate precede the related conditional block.
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.