8.6.11.8 IF, ELSEIF, ELSE and ENDIF Commands

Syntax

if expression

commands...

[ elseif expression ]

[ commands ]

[ else ]

[ commands ]

endif

Description

The if command evaluates the expression; if it is true (nonzero), the following commands are executed; otherwise, they are skipped until the next elseif, else or endif command. The commands following an else command are executed only if the corresponding if expression was false. Elseif commands are equivalent to nested if's as shown by the following equivalent examples:

if expression1 if expression1

commands ...1 commands ...1

elseif expression2 else

commands ...2 if expression2

elseif expression3 commands ...2

commands ...3 else

else if expression3

commands ...4 commands ...3

endif else

commands ...4

endif

endif

endif

The built-in if command is only available when menu has the built-in menu commands enabled.

Example

ask "Enter new RMSfile name: " as string to newname

if file newname

echo "File already exists."

exit 1

else

makelf $newname 100

endif