IF - DO - ELSE

Purpose

Allows conditional execution of command scripts.

Syntax

IF #const DO scriptfile1  { ELSE scriptfile2  } @

Arguments and Subcommands

IF #const

A named constant used as a logical variable for the IF condition. The condition is true if the value of #const is non-zero, and false otherwise.

DO scriptfile1

The name of the script to execute if condition #const is not zero (true).

ELSE scriptfile2

The name of the script to execute if condition #const is zero (false).

Remarks

Note this command is intended for use with command scripts and should not be confused with the IF-THEN-ELSE-ENDIF operation that can be used in transformations. The condition must be a single named constant; relational and logical expressions are not allowed. The IF -DO- ELSE command is used in the IFEXAM.PNT example.

Examples

a)  Run the script DOPROF.SCR if the fit was successful.

FIT @
CONS #fitok = #fitstat== 0 @
IF #fitok DO doprof.scr @

b)  Run the script DOPROF.SCR if the fit was successful; otherwise run the REFIT.SCR script.

FIT @
IF #fitstat DO refit.scr ELSE doprof.scr @