Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
raghavmcs

Active User

Joined: 14 Jul 2005
Posts: 105

 Posted: Sat Dec 20, 2008 12:13 am    Post subject: RExx code to accept input from user 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

enrico-sorichetti

Senior Member

Joined: 14 Mar 2007
Posts: 10478
Location: italy

 Posted: Sat Dec 20, 2008 12:20 am    Post subject: Reply to: RExx help homework ?? what did You try, up to now,,, post something ( even errors ) and somebody will be glad to advice
raghavmcs

Active User

Joined: 14 Jul 2005
Posts: 105

 Posted: Sat Dec 20, 2008 12:55 am    Post subject: Reply to: RExx help I tried Stem concept.Bust stuck next,anyway I feel like you want me to learn REXX and be the expert :-)
raghavmcs

Active User

Joined: 14 Jul 2005
Posts: 105

 Posted: Sat Dec 20, 2008 12:57 am    Post subject: Reply to: RExx help 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
enrico-sorichetti

Senior Member

Joined: 14 Mar 2007
Posts: 10478
Location: italy

 Posted: Sat Dec 20, 2008 1:00 am    Post subject: Reply to: RExx help first of all, where did the assignment come from ?? ( it does not make too much sense )
Douglas Wilder

Active User

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

 Posted: Sat Dec 20, 2008 3:53 am    Post subject: 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.
expat

Global Moderator

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

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

 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
ofer71

Global Moderator

Joined: 27 Dec 2005
Posts: 2360
Location: Israel

Posted: Sun Dec 21, 2008 12:54 pm    Post subject:

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

O.
Pedro

Senior Member

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

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

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
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics What will happen if we dont code STOP... Poha Eater COBOL Programming 4 Mon Jun 04, 2018 5:27 pm JCL to set Return code when Time Out ... vinu78 JCL & VSAM 6 Wed May 30, 2018 11:27 am Rexx code to find greater then symobl... Bharath Vikraman CLIST & REXX 8 Tue May 29, 2018 9:40 am RESP2 code -502 pshongal CICS 6 Mon May 28, 2018 10:58 am Code Coverage and static analysis too... Aditya.Srivastava PL/I & Assembler 2 Fri May 25, 2018 12:48 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us