# IF, ELSE, ENDIF > [HTML Version](else_lit.htm) _Updated May 2026; see History_ **IF ** **ELSE** **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](commandfiles.htm.md) 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](exit_lit.htm.md) command exits entirely out of the CMD/DO file, regardless of the depth of IF/ENDIF nesting, unlike the ASB [EXIT](exit.htm.md) control statement. IF "\$0" = "" : 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 **History** 2026 May, A-Shell 1786: Update IF.LIT (x.x.xxx) and ECHO.LIT (x.x.xxx) to support a new variable (\$?) that equates to the exit status of the last module execution. For example: RUN PROG1 ECHO PROG1 Exit Status: \$? IF \$? <> 0 ECHO Error, cannot continue GOTO ENDIT ELSE RUN PROG2 ENDIF ;ENDIT Note that this variable is not recognized by DO.LIT.