Joined: 03 Oct 2009 Posts: 1786 Location: Bloomington, IL
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).
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"<<"
say right(i,2) "the "left(word(ordern,i),7)" token is >>"tokn.i"<<"
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 )