REXX and Batch Files

You can use a REXX program anywhere you now use OS/2 batch files. The following example shows an OS/2 batch file that processes user input to display a help message:

@echo off
if %1.==. goto msg
if %1 == on goto yes
if %1 == off goto no
if %1 == ON goto yes
if %1 == OFF goto no
if %1 == On goto yes
if %1 == oN goto yes
if %1 == OFf goto no
if %1 == OfF goto no
if %1 == Off goto no
if %1 == oFF goto no
if %1 == oFf goto no
if %1 == ofF goto no
helpmsg %1
goto exit
:msg
helpmsg
goto exit
:yes
prompt $i[$p]
goto exit
:no
cls
prompt
:exit

Here is the equivalent program in REXX:

/* HELP.CMD -- Get help for a system message */
arg action .
select
  when action=''    then     'helpmsg'
  when action='ON'  then     'prompt $i[$p]'
  when action='OFF' then do
                           'cls'
                           'prompt'
                           end
  otherwise 'helpmsg' action
  end
exit


[Back: Suppressing the Command Echo]
[Next: Issuing a Command to Call a .CMD File]