Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

RExx code to accept input from user

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Sat Dec 20, 2008 12:13 am    Post subject: RExx code to accept input from user
Reply with quote

Dear Experts,

I do not have much knowledge of REXX.If someone can give me a piece of code for following will be great.
a)Say 123456789 is a ninie digit number.I want this number to be taken from the user and then
Getting the second last digit like in this case its 8.
Next step is adding 1 to it which maked 9 in this case
Display the outout 9 in this case

But there is an exception of output and that is for
when the second digit from last is 9.IN this case 9+1 will make 10.But in this case the output should be 0.

I know that its easy task for someone who knows REXX.I have to get this done urgently and my current REXX skill are not helping me out to get this.
Hope I am not bugging any of the experts here,thanks
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Sat Dec 20, 2008 12:20 am    Post subject: Reply to: RExx help
Reply with quote

homework ??

what did You try, up to now,,,

post something ( even errors ) and somebody will be glad to advice
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Sat Dec 20, 2008 12:55 am    Post subject: Reply to: RExx help
Reply with quote

I tried Stem concept.Bust stuck next,anyway I feel like you want me to learn REXX and be the expert :-)
Back to top
View user's profile Send private message
raghavmcs

Active User


Joined: 14 Jul 2005
Posts: 105

PostPosted: Sat Dec 20, 2008 12:57 am    Post subject: Reply to: RExx help
Reply with quote

I was trying like this.Please do not see the digits and the number of digits.

Not sure am on right track to achieve this
VAR1=RIGHT( '102301123',2)
VAR2=RIGHT('VAR1',1)
VAR3=VAR2+1
SAY VAR1
SAY VAR2
SAY VAR3
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Sat Dec 20, 2008 1:00 am    Post subject: Reply to: RExx help
Reply with quote

first of all, where did the assignment come from ??
( it does not make too much sense )
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Sat Dec 20, 2008 3:53 am    Post subject:
Reply with quote

It look like you are coming along fine on coding this.
To be on the safe side it is good for the first line of a REXX to contain /* REXX */.
If you need to get the input from the keyboard try using "Parse Upper Arg".
For your exception processing use an "IF THEN ELSE".
There is no batter way to learn any programming language than to try it, and when needed get pointers (not the answers) from someone else who knows the language.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Sat Dec 20, 2008 3:54 pm    Post subject: Re: Reply to: RExx help
Reply with quote

raghavmcs wrote:
I was trying like this.Please do not see the digits and the number of digits.

Not sure am on right track to achieve this
VAR1=RIGHT( '102301123',2)
VAR2=RIGHT('VAR1',1)
VAR3=VAR2+1
SAY VAR1
SAY VAR2
SAY VAR3

Unfortunately, the syntax is almost correct but the logic is not. The logic will return the LAST digit from the string.

Syntax - Where you have VAR2=RIGHT('VAR1',1) by enclosing the word VAR1 in quotes you are using a literal rather than the value stored in the VAR1 variable.

Logic - Try this
Code:

VAR2 = LEFT(VAR1,1)
VAR3 = VAR2 + 1
IF VAR3 > 9 THEN VAR3 = 0
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Sun Dec 21, 2008 12:54 pm    Post subject:
Reply with quote

Another version:
Code:

/* REXX */                                                             
                                                                       
A = '123456789'                                                         
B = RIGHT(SUBSTR(REVERSE(STRIP(A)),2,1)+1,1)                           
                                                                       
SAY A                                                                   
SAY B                                                                   
                                                                       
EXIT                                                                   
                                                                       


O.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2025
Location: Silicon Valley

PostPosted: Mon Dec 22, 2008 9:16 pm    Post subject: Reply to: RExx code to accept input from user
Reply with quote

O.'s example works. But in instances like this, I prefer using the PARSE instruction:

Code:
/* REXX */                                                             
                                                                       
A = '123456789'                                                         
PARSE VAR a 8 b 9 .                         
                                                                       
SAY A                                                                   
SAY B                                                                   
                                                                       
EXIT 
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us