InterSystems IRIS Data Platform 2019.2  /  ObjectScript Reference

ObjectScript Reference
Previous section           Next section
InterSystems: The power behind what matters   

Clause of block-oriented IF command.
ELSE { code }
Refer to IF command for complete syntax.
ELSE is not a separate command, but a clause of the block-oriented IF command. You can specify a single ELSE clause as the final clause of an IF command, or you can omit the ELSE clause. Refer to the IF command for details and examples.
An earlier version of the ELSE command may exist in legacy applications where it is used with a line-oriented IF command. These commands may be recognized because they do not use curly braces. The old and new forms of IF and ELSE are syntactically different and should not be combined; therefore, an IF of one type should not be paired with an ELSE of the other type.
The earlier line-oriented ELSE command could be abbreviated as E. The block-oriented ELSE keyword cannot be abbreviated.
The ELSE keyword must be followed by an opening and closing curly brace ({) and (}). Usually these curly braces enclose a block of code. However, an ELSE with no code block is permissible, as in the following:
   SET x=1
   IF x=1{
          WRITE "Once only"
          SET x=x+1
          GOTO Loop
   WRITE !,"All done"
There are no whitespace restrictions on the ELSE keyword.
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-08-23 06:48:00