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

Delimiters in REXX


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

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Dec 19, 2008 4:57 pm
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 ,
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: 459
Location: Belgium

PostPosted: Fri Dec 19, 2008 5:01 pm
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: 1742
Location: Tirupur, India

PostPosted: Fri Dec 19, 2008 5:05 pm
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: 459
Location: Belgium

PostPosted: Fri Dec 19, 2008 5:12 pm
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: 1742
Location: Tirupur, India

PostPosted: Fri Dec 19, 2008 5:18 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Dec 19, 2008 5:19 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Dec 19, 2008 5:22 pm
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: 1742
Location: Tirupur, India

PostPosted: Fri Dec 19, 2008 6:25 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Dec 19, 2008 6:28 pm
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: 1742
Location: Tirupur, India

PostPosted: Fri Dec 19, 2008 6:31 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top