|
View previous topic :: View next topic
|
| Author |
Message |
chandru1483
New User
Joined: 17 Dec 2010 Posts: 3 Location: bangalore
|
|
|
|
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 |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| 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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| 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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|