UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

$IFDEF Syntax 1-31 UniBasic Commands Reference $IFDEF var statements1 [$ELSE statements2] $ENDIF Description The UniBasic $IFDEF command conditionally compiles UniBasic statements depending on the existence of a variable definition. Variables are defined by $DEFINE. Parameters The following table describes each parameter of the syntax. Parameter Description var Specifies variable to check to determine whether to compile statements1 or statements2. statements1 Specifies statements to compile if var is defined. statements2 Specifies optional statements to compile if var is not defined. $IFDEF Parameters Examples In the following example, when you compile the program segment, the system defines array1 as a 10-element array initialized with 0: $DEFINE SMALL $IFDEF SMALL DIM array1(10) MAT array1 = 0 $ENDIF

In the next example, when you compile the program segment, the system defines array1 as a 100-element array and initializes it with 1: $UNDEFINE SMALL $IFDEF SMALL PRINT 'SMALL was defined' $ELSE DIM array1(100) MAT array1 = 1 $ENDIF Related Commands UniBasic $DEFINE, $IFNDEF $IFDEF 1-32

In the next example, when you compile the program segment, the system defines<br />

array1 as a 100-element array and initializes it with 1:<br />

$UNDEFINE SMALL<br />

$IFDEF SMALL<br />

PRINT 'SMALL was defined'<br />

$ELSE<br />

DIM array1(100)<br />

MAT array1 = 1<br />

$ENDIF<br />

Related <strong>Commands</strong><br />

<strong>UniBasic</strong><br />

$DEFINE, $IFNDEF<br />

$IFDEF 1-32

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

Saved successfully!

Ooh no, something went wrong!