Home | OS/2 Software | Rexx | Simple template with variations to check command line input (Beginning level)

Simple template with variations to check command line input (Beginning level)

Contributed by: Doug Rickman, Global Hydrology and Climate Center, MSFC, NASA

This is aimed at beginning REXX users.


 


/*****************************************************************************/
/***  Initial input/output and line error check and help   *******************/

if in='' | in='?' | in='-?' | in='/?' then call Help

if dosisfile(in)<>1 then do
   say 'The input file: ' in' is not a valid file.'
    exit
    end /* do */

if dosisfile(out) then do
   say 'The file ' out' already exists, do you want it overwritten?'
    say 'Enter a "y" for yes, "h" will give help,'
    say 'any other response will abort processing.'
    key=translate(sysgetkey())

    select
        when key='Y' then rc=dosdel(out)
        when key='H' then call Help
        otherwise exit
        end /* select */
    end /* if dosisfile(out) */


if verify(Input,'1234567Y')<>0 then do
    say ''
    say 'You have entered an option I do not understand'
    say 'Do you want help?'
    say 'Enter a "y" for yes, any other response will abort processing.'
    key=sysgetkey('NOECHO')
    if translate(key)='Y' then call Help
    exit
    end /* if Option....*/
if Input='' then do
    say 'what this program does'
    say ''   
    say 'Is this what you want to do?'
    say 'Enter a "y" for yes, "h" will give help,'
    say 'any other response will abort processing.'
    key=sysgetkey('NOECHO')
    if translate(key)='H' then call Help
    if translate(key)='Y' then nop
        else exit
    end /* if Input='' then do */