Revised May 2025
IF <expr>
<statement(s) to execute if true>
ELSE
<statement(s) to execute if false>
ENDIF
IF, ELSE and ENDIF allow for the flow of control within a CMD or DO file based on various conditions that can be tested. IF takes an expression that evaluates to true or false, while ELSE and ENDIF take no arguments. See the example below and Command Files for more information.
Example
This DO file takes a filename argument, without extension. If the filename doesn't exist (with a BAS extension), it is created by copying from another file and then loaded into VUE. If no argument is supplied, or the file already exists, it prints an error message and exits. Note that the EXIT command exits entirely out of the CMD/DO file, regardless of the depth of IF/ENDIF nesting, unlike the ASB EXIT control statement.
IF "$0" = ""
:<This command needs a filename argument>
EXIT ; exit DO file
ELSE
IF LOOKUP("$0.BAS") = 0 ; if file does not exist
COPY $0.BAS=APPLIB:STDHDR.TXT
ELSE
:<$0.BAS already exists; command aborted>
EXIT ; exit DO file
ENDIF
ENDIF
VUE $0.BAS