IF ELSE ENDIF

Action

Conditionally runs statements.

 

Syntax

IF expression
statement1
      ....
[ELSE
      statement2
       ....       ]
ENDIF

 

Remarks

The body of an IF statement is executed selectively depending on the value of the expression. If expression is true, then statement1 is executed. If expression is false and the ELSE clause is specified, then statement2 is executed.

 

IF statements can be nested as many times as memory allows.

 

 

If the expression does not contain any relational operators, the condition is considered to be true if it is numeric and it evaluates to a value other than zero, or if it is alphanumeric and it evaluates to a string containing at least one character.

 

Note that by default, all string comparisons are made case-insensitive. This behavior can be changed using the SetOption function. Please see the description of the SetOption function for full details.

 

 

Examples

IF $X                 ; similar to IF $X <> 0

    ; do stuff

ENDIF

 

IF @HOMESHR               ; similar to IF @HOMESHR <> ""

    ; do stuff

ENDIF

 

IF INGROUP("Admins")      ; similar to IF INGROUP("Admins") > 0

    ; do stuff

ENDIF

 

IF NOT INGROUP("Domain Admins")  ; true if user NOT a Domain Admin

    ; do stuff

ENDIF

 

IF $X*2 < 10

    ; do stuff

ENDIF

 

IF (($X*2) < 10) OR ($Y + 100) /3 >120

    ; do stuff

ENDIF

 

IF INSTR(%PATH%,"NETLOGON") AND @DOS = "3.51"

    ; do stuff

ENDIF

 

IF (SUBSTR(@WKSTA,11,1)="1" AND @USERID = "PETERV") OR  @DOMAIN = "VleerBeer"

    ; do stuff

ENDIF

 

IF @USERID = "RUUDV" OR @USERID = "WIMW"

    ; do stuff

ENDIF

 

IF (INGROUP("Domain Users") OR INGROUP("Users"))

    ; do stuff

ENDIF