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

how to seperate the words which are with commas


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

New User


Joined: 17 Dec 2010
Posts: 3
Location: bangalore

PostPosted: Tue Feb 08, 2011 5:21 pm
Reply with quote

if there is a sentance like (Ant, Car, Rat)

I want the output to be

The first word is Ant
The second word is Car
The third word is Rat


How it is possible using Rexx ?

Can any one kindly let me knw ?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Feb 08, 2011 5:28 pm
Reply with quote

chandru1483 wrote:
if there is a sentance like (Ant, Car, Rat)

I want the output to be

The first word is Ant
The second word is Car
The third word is Rat


How it is possible using Rexx ?

Can any one kindly let me knw ?

You can use PARSE VALUE, if the number of tokens is known, or POS and SUBSTR in a loop, if it is not (you could actually use PARSE VALUE there, too; I think that POS/SUBSTR logic will be more understandable. Feel free not to agree).
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 08, 2011 5:44 pm
Reply with quote

Code:
string= "one,two, three ,four, five ,six ,seven, eight, nine ,more ,more, more, more"
ordern= "first second third fourth fifth sixth seventh eighth ninth"
do  i = 1 while ( string <> "" )
    parse var string tokn "," string
    tokn.i = strip(tokn)
    if  i > 9 then ,
        say right(i,2) "the umpteen token is >>"tokn.i"<<"
    else
        say right(i,2) "the "left(word(ordern,i),7)" token is >>"tokn.i"<<"
end

but You might willing to find an algorithmic solution to obtain for a number
the same in words and the relatibe ordinal ( always in words )
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 To find an array of words (sys-symbol... JCL & VSAM 9
No new posts Remove commas from specific positions... DFSORT/ICETOOL 10
No new posts To fetch value separated by commas fr... DB2 3
No new posts Using ICETOOL, how we can seperate th... SYNCSORT 5
No new posts Splitting of single report to seperat... TSO/ISPF 7
Search our Forums:

Back to Top