11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ELSEIF and ELSE clauses are optional, but it is a good programming practice to alwaysspecify an ELSE clause.IF is a block-oriented command. Each command keyword is followed by a block of codeenclosed in curly braces. Within these curly braces you can freely use line returns, indents,and blank spaces as desired.IFNote:An earlier, line-oriented version of the IF command may exist in legacy applications.This form of IF does not use curly braces or support the ELSEIF clause. These twoforms of IF are syntactically different and should not be combined. Thus, an IF ofone type should not be paired with an ELSE of the other type. The earlier line-orientedELSE could be abbreviated as E; the block-oriented ELSE keyword shouldnot be abbreviated.The IF command evaluates expression1 and, if expression1 is TRUE, it executes the blockof commands within the curly braces that follow it, and the IF command completes.If expression1 is FALSE, execution jumps to the next clause of the IF statement. It evaluatesthe first ELSEIF clause (if present). If expression2 in the ELSEIF clause is TRUE, theELSEIF code block is executed and the IF command completes. If expression2 is FALSE,the next ELSEIF clause is evaluated. Each successive ELSEIF clause is tested in the orderlisted until one of them evaluates TRUE, or all of them evaluate FALSE.If the IF clause and all ELSEIF clauses evaluate to FALSE, execution continues with theELSE clause. The ELSE clause block of code executes, and the IF command completes. Ifno ELSE clause is present, the IF command completes.Argumentsexpression1A test condition for the IF clause. It can take the form of a single expression or a commaseparatedlist of expressions. For an expression list, <strong>Caché</strong> evaluates the individual expressionsin left to right order. It stops evaluation if it encounters an expression that is FALSE. If allexpressions evaluate to TRUE, <strong>Caché</strong> executes the block of code associated with the clause.This block of code is enclosed in curly braces. If any expression evaluates to FALSE, <strong>Caché</strong>ignores any remaining expressions, and does not execute the block of code associated withthe clause. An IF clause list of expressions should not be broken into multiple lines.expression2A test condition for an ELSEIF clause. It can take the form of a single expression or a commaseparatedlist of expressions. It is evaluated the same way as expression1.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!