Rexx and Batch Files

You can use a Rexx program whenever you now use Windows batch files or Unix/Linux shell scripts. The following example shows a Windows 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