:If, :Endif, :Else, :Elseif Commands
In command files, UDCs, usefiles, and even from the /-prompt, use If, Endif, Else and Elseif commands to create conditional logic. See also the While command, the /Qedit command and the INSIDEQEDIT JCW.
:IF expression [THEN]
:ELSEIF expression [THEN]
:ELSE
:ENDIF
Examples
Here is a sample command file to show a specific session or all sessions on the system. The parameter is the session number, which the If tests for zero default value in deciding whether to show one or all sessions:
PARM sessnum=0 setjcw jsnum=!sessnum if jsnum=0 then showjob job=@s else showjob #s!sessnum endif
To invoke this command, put it in a file named “SS”, then type the file name, optionally followed by a session number:
/ss /ss 456
Although :If commands may be nested up to 30 levels deep, :Elseif provides an alternative, effectively giving you a “case” command. Any number of Elseifs may follow an If, but only one Else may follow an If or Elseif. The “Then” keyword is optional in Elseif, and in If as well.