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.

IF (legacy version)IF (legacy version)Evaluates an expression, then selects which line of code to execute based on the truth valueof the expression.IF expression1 command1command2DescriptionNote:This page describes the legacy version of the IF command. This version is obsoleteas of <strong>Caché</strong> 4.0, and should not be used in new programming. It is described heresolely for compatibility with legacy applications.The legacy IF command is line-oriented; commands to be executed must follow iton the same program line. Curly braces are not used and line formatting is restrictive.The new IF command is block structured; the block it executes consists of commandsfound within the curly braces that follow the IF command. Line formatting (whitespace, line breaks) is unrestrictive. The new version of IF does not use the $TESTspecial variable.The old and new forms of IF and ELSE are syntactically different and should notbe combined; therefore, an IF of one type should not be paired with an ELSE of theother type.The IF command has two forms:Without an argumentWith an argumentIF Without an ArgumentIF without an argument executes the commands that follow it on the same line if the currentvalue of the $TEST variable is TRUE (non-zero). If $TEST is FALSE (0), <strong>Caché</strong> ignoresthe remaining commands and continues execution with the next line.IF With an ArgumentIF with the argument expression1 executes the commands that follow it on the same line ifexpression1 evaluates to TRUE (non-zero). (<strong>Caché</strong> also sets $TEST to TRUE.) If expression1evaluates to FALSE, <strong>Caché</strong> sets $TEST to FALSE (0), ignores the remaining commands onthat line, and continues execution with the next line.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 753

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

Saved successfully!

Ooh no, something went wrong!