MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing variable no of arguments

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
bidpar
Beginner


Joined: 08 Jan 2003
Posts: 28
Topics: 4
Location: india

PostPosted: Fri Jun 06, 2003 7:58 am    Post subject: Passing variable no of arguments Reply with quote

Hi all
Learning REXX.
How can I pass different no of arguments to a REXX program ?
I have written a small program to read the argument list and print it. I used the following method

numarg = ARG()
say numarg
Do i = 1 to numarg
say 'arg(' || i || ') =' || ARG(i)
end

I am running this program as TSO EX 'PDS.NAME(MEMBER)' '1 2 3'
All my variables 1 2 &3 are getting associated to arg(1). It is showing arg(1) = '1 2 3' and numarg = 1
I want
arg(1) = 1
arg(2) = 2
arg(3) = 3.

Also I should be able to run this program with different set of variables like TSO EX 'PDS.NAME(MEMBER)' '1 2 3 4 5' without changing the program and the output should look like following
arg(1) = 1
arg(2) = 2
arg(3) = 3
arg(4) = 4
arg(5) = 5

Is this possible in REXX?
I tried exploring the PARSE ARG option without any success.

Regards
Bidpar
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jun 06, 2003 8:30 am    Post subject: Reply with quote

Instead of parse option, you can use WORDS() function. This will give you no of variables in the input argument (separated by spaces).

Try this:
Code:

numarg = WORDS(arg_variable)
ARG(1) =  WORD(arg_variable, 1)
ARG(2) =  WORD(arg_variable, 2)


and so on

Hope this helps,
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jun 06, 2003 8:33 am    Post subject: Reply with quote

Sorry, the code was incomplete, Use this.

Code:

numarg = WORDS(arg_variable)
do I = 1 TO numarg
        say 'arg(' || i || ') =' || WORD(arg_variable, I)
end


WORD(variable, n) will return the n'th word in the input variable.

Thanks
Back to top
View user's profile Send private message
bidpar
Beginner


Joined: 08 Jan 2003
Posts: 28
Topics: 4
Location: india

PostPosted: Wed Jun 11, 2003 1:42 am    Post subject: Reply with quote

Working fine.
Thank you Phantom.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group