Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Delimiters in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1521
Location: Chennai

PostPosted: Fri Dec 19, 2008 4:57 pm    Post subject: Delimiters in REXX
Reply with quote

Hi All icon_biggrin.gif ,

Is there any way to read character delimited files in REXX.(i.e reading @ delimited files or $ delimited files.
Rexx understands space delimited words so we can split the data with WORD function icon_biggrin.gif , but
is REXX capable of splitting words delimited by other characters, say '@' or $ with any functions and without the brute force method.

Our forum with the search string as 'delimit' gives this link icon_eek.gif ,
http://ibmmainframes.com/viewtopic.php?t=34762&highlight=delimit

I tried the TSO-E/REXX manual and it says only about blank icon_eek.gif delimiters and " delimiters.

WORD
 WORD(string,n) 
returns the nth blank-delimited word in string or returns the null string if fewer than
n words are in string. The n must be a positive whole number. This function is
exactly equivalent to SUBWORD(string,n,1).
Here are some examples:
WORD('Now is the time',3) -> 'the'
WORD('Now is the time',5) -> ''


The file that needs to be read has the following structure, and it is not column delimited icon_mad.gif
51847@00000001@51041220@041220@1@0000000@


Could you please show some light in the tunnel? icon_question.gif
Back to top
View user's profile Send private message

PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Fri Dec 19, 2008 5:01 pm    Post subject:
Reply with quote

If there are no blanks anywhere in the record, translate @ to blank,
then process by word.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1521
Location: Chennai

PostPosted: Fri Dec 19, 2008 5:05 pm    Post subject:
Reply with quote

Hi PeD,

Thanks for your time, icon_biggrin.gif icon_biggrin.gif

But unfortunately there are blanks in the input file icon_mad.gif

Thanks in advance,
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Fri Dec 19, 2008 5:12 pm    Post subject:
Reply with quote

In this case, you will have to play INDEX or POS in a loop.
If I had to do that, my approach will be that one.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1521
Location: Chennai

PostPosted: Fri Dec 19, 2008 5:18 pm    Post subject:
Reply with quote

Omg icon_sad.gif That looks like mammoth task...
I wish there was a simple function like "WORD"


Also there are 100's of variables so was unable to use the below example,


"EXECIO 1 DISKR indd"
PARSE PULL record
PARSE VAR record fld1 ',' fld2 ',' fld3 ',' fld4 ',' ...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10310
Location: italy

PostPosted: Fri Dec 19, 2008 5:19 pm    Post subject: Reply to: Delimiters in REXX
Reply with quote

Code:
string = "abcd$efg$hi h$ k $s eee$eeer"
parse var string t1 "$" t2 "$" t3 "$" t4 "$" t5 "$" t6 "$" t7 "$" tail

say "t1  >"t1"<" 
say "t2  >"t2"<" 
say "t3  >"t3"<" 
say "t4  >"t4"<" 
say "t5  >"t5"<" 
say "t6  >"t6"<" 
say "t7  >"t7"<" 
say "tail>"tail"<"

Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Dec 19, 2008 5:20 pm    Post subject:
Reply with quote

hi,

i tried something like this. not sure if it fits ur requirement:

Code:

rec = '51847@00000001@51041 220@041 220@1@000 0000@'
tmprec = rec                                         
i = 1                                               
do while tmprec <> ''                               
parse value tmprec with tmpwrd '@' extra             
tmprec = extra                                       
say 'Word' i '=' tmpwrd                             
say extra                                           
i = i + 1                                           
end                                                 
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10310
Location: italy

PostPosted: Fri Dec 19, 2008 5:22 pm    Post subject: Reply to: Delimiters in REXX
Reply with quote

follow on

Code:
string = "51847@00000001@51041220@041220@1@0000000@"
parse var string t1 "@" t2 "@" t3 "@" t4 "@" t5 "@" t6 "@" t7 "@" tail

say "t1  >"t1"<" 
say "t2  >"t2"<" 
say "t3  >"t3"<" 
say "t4  >"t4"<" 
say "t5  >"t5"<" 
say "t6  >"t6"<" 
say "t7  >"t7"<" 
say "tail>"tail"<"


result
Code:
enrico-pBook:~ enrico$ ./test.rx
t1  >51847<
t2  >00000001<
t3  >51041220<
t4  >041220<
t5  >1<
t6  >0000000<
t7  ><
tail><
enrico-pBook:~ enrico$
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1521
Location: Chennai

PostPosted: Fri Dec 19, 2008 6:25 pm    Post subject:
Reply with quote

Hi genesis786,

Thanks for the code, I works like a charm icon_biggrin.gif icon_biggrin.gif
Exactly what I needed.

Enrico,
Thanks to you too for providing a super simple method..


Im gona celebrate this... icon_biggrin.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10310
Location: italy

PostPosted: Fri Dec 19, 2008 6:28 pm    Post subject: Reply to: Delimiters in REXX
Reply with quote

Quote:
Thanks to you too for providing a super simple method..


I did not provide anything... REXX did it icon_biggrin.gif

and how to exchange the value of two variables in one shot ???
( only limitations is no blanks in the variable content )

Code:
a = "xxxx"
q = "zzzz"
say "a >"a"<"
say "q >"q"<"
parse value a q with q a
say "a >"a"<"
say "q >"q"<"
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1521
Location: Chennai

PostPosted: Fri Dec 19, 2008 6:31 pm    Post subject:
Reply with quote

This looks like the Tumblers and ball magic trick.... icon_biggrin.gif

nice
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Creating ISPF Screens with Scrname vi... Albireo20 TSO/ISPF 9 Tue Sep 05, 2017 4:24 pm
No new posts How to Run Rexx Macro? Kalaivignesh CLIST & REXX 5 Fri Sep 01, 2017 9:08 pm
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us