A very useful ability in almost any programming language is to that of passing in command-line arguments.
The usage syntax for this in REXX scripting is
Parse Argument1 Argument2 Argument3 .
The command Parse, will parse in anything that was passed in when the script was called, following the parse template.
/**/
Parse Arg Cust sDate .
ActiveFlag = '\settle\bin\active.flg'
sDate = Date('S')
/* Main (Start) */
Select
When Cust = '' | sDate = '' then Do
Say ''
Say 'Usage: Settle [Cust] [sdate]'
Say ''
Say 'Options:'
Say ' cust customer 3 digit code' /* Display usage message */
Say ' sdate settle date [mmddyy]'
Say ''
Exit;
End /* Do */
In our exmaple here, we are expecting the user to provide us with two arguments. The customer number & the date. We check the value of the arguments passed in, & in the event that they are empty, we act accordingly by prompting the user to use the command correctly.
You'll also notice the period the follows the expected arguments. This will absorbe anything unexpected that might be remaining on the command line.
In fact, one of the most powerful features of REXX is its ability to parse text values. So keep in mind that Parse can be used for more than just reading in command-line arguments.
Here is another example of the parse command within the script itself.
/**/ parse value 'Show another example' with word1 word2 word3 say "'"word1"'" say "'"word2"'" say "'"word3"'"
The output would be:
Quote
'Show'
'another'
'example'
'another'
'example'




MultiQuote


|