IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to operate Character variable in Loop?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ruodeer

New User


Joined: 06 Jul 2007
Posts: 58
Location: home

PostPosted: Thu Nov 29, 2007 8:02 am
Reply with quote

I have a requirement:

want to generate strings A1 - Z9(A1,A2.....B1...Z9) in Rexx,
I try to write following Loop clause but get syntax error.

Code:
do i='A' to 'Z'    <-----  here is detected error!
    do j=1 to 9
        say "generated:"||i||j
    end
end


could some friends help me out on this ? thanks!
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Thu Nov 29, 2007 9:09 am
Reply with quote

Hi,

I hope the below code will meet your requirement.

Code:
LP='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
DO I= 1 TO 26
STR = SUBSTR(LP,I,1)
    DO J=1 to 9
        SAY "GENERATED:"||STR||J
    END
END


Thanks
Sai
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Nov 29, 2007 8:29 pm
Reply with quote

Hello,

Quote:
I try to write following Loop clause but get syntax error.
The error is because 'A' and 'Z' are not numeric.

Also, keep in mind that even if the process could increment from A to Z, there are values between A and Z that you would not want.

For example the letter I is x'C9' - the letter J is x'D1'. Your process (if it could work) would include the values from x'CA' thru x'CF' and i'm sure you would not want them.
Back to top
View user's profile Send private message
ruodeer

New User


Joined: 06 Jul 2007
Posts: 58
Location: home

PostPosted: Fri Nov 30, 2007 7:16 am
Reply with quote

Hi , thank you saiprasadh and Dick.
Now it is clear to me.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Nov 30, 2007 8:36 am
Reply with quote

You're welcome icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
This topic is locked: you cannot edit posts or make replies. REXX - Do - Not able to LOOP CLIST & REXX 10
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top