Welcome to Dream.In.Code
Getting Help is Easy!

Join 118,589 Programmers for FREE! Ask your question and get quick answers from experts. There are 811 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Parsing command-line argumnts in a REXX script

 
Reply to this topicStart new topic

Parsing command-line argumnts in a REXX script

no2pencil
post 10 May, 2008 - 11:43 PM
Post #1


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 5,512



Thanked 36 times

Dream Kudos: 2350

Expert In: Goofing Off

My Contributions


Parsing command-line argumnts in a REXX script

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
CODE

Parse Argument1 Argument2 Argument3 .


The command Parse, will parse in anything that was passed in when the script was called, following the parse template.

CODE

/**/
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.
CODE

/**/
parse value 'Show another example' with word1 word2 word3
  
  say "'"word1"'"
  say "'"word2"'"
  say "'"word3"'"


The output would be:
QUOTE

'Show'
'another'
'example'
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/11/08 07:49PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month