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

Join 132,479 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,256 people online right now. 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 - 10:43 PM
Post #1


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,329



Thanked 57 times

Dream Kudos: 2375

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 online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 02:59PM

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