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

Line continuation in REXX


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

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Mon Dec 12, 2011 11:50 pm
Reply with quote

Hi,

In my REXX code there is a variable where I am editing some values.
The variable is like

Code:
ORC=ST1","ED1","VRX1"X,",
    ST2","LN2","VRX2"X,",
    ST3","LN3           


The last ',' (comma) I used is for continuation to next line. But because of this one blank is coming unnecessarily. It is coming as

Code:
ORC= 1,4,5, 2,5,6, 3,6


But my expectation is
Code:
ORC= 1,4,5,2,5,6,3,6



Can any one tell me where I am doing the mistake?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Dec 12, 2011 11:58 pm
Reply with quote

What are you trying to do with the X?

Have you tried something like to trace the intermediate values?
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Tue Dec 13, 2011 12:03 am
Reply with quote

Hi Bill,

Actually I am substituting the values in a sort card.

The code snippet is slightly wrong. It has to be


Code:
ORC= 1,4,5x, 2,5,6x, 3,6


These values are getting substituted in the skel JCL. Hence trace is not hlpng me.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Tue Dec 13, 2011 12:10 am
Reply with quote

Using a comma to continue a string constant implicitly infixes an extra space. Do this:
Code:
ORC=ST1","ED1","VRX1"X," ||,
    ST2","LN2","VRX2"X," ||,
    ST3","LN3       
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Dec 13, 2011 12:17 am
Reply with quote

Quote:

These values are getting substituted in the skel JCL. Hence trace is not hlpng me.


You already have the solution, from the learned (you have to get the emphasis correct on that one, think of courtroom dramas from the UK...) Mr Akatsukami. Next time you have a snippet you think you can't trace, copy it somewhere else where there is nothing else to interfere with it, and then trace it.
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Tue Dec 13, 2011 12:20 am
Reply with quote

There are several to do this..

Code:
ORC = ST1||','||ED1||','||VRX1||'X,'||,
      ST2||','||LN2||','||VRX2||'X,'||,
      ST3||','||LN3
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Tue Dec 13, 2011 12:26 am
Reply with quote

Thanks Akatsukami.

It is working fine now.

But I really didn't inderstood how it is working. If you can put some light on it then it it will be helpful.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Tue Dec 13, 2011 1:01 am
Reply with quote

Priyanka Pyne wrote:
Thanks Akatsukami.

It is working fine now.

But I really didn't inderstood how it is working. If you can put some light on it then it it will be helpful.

As you will know, there are three ways of doing string concatenation in Rexx:
  1. With an explicit concatenation operator. The result of
    Code:
    foo = "BAR"
    foo = foo || "ABBAS"
    say foo

    is "BARABBAS".
  2. By abutting the arguments. The result of
    Code:
    foo = "BAR"
    foo = foo"ABBAS"
    say foo

    is also "BARABBAS".
  3. By listing the arguments as rvalues (to the right of the assignment operator). The result of
    Code:
    foo = "BAR"
    foo = foo "ABBAS"
    say foo

    is "BAR ABBAS". Note the infixed space; listing the arguments as rvalues implicitly concatenates a space between each one.

Now, look at your code snippet:
Code:
ORC=ST1","ED1","VRX1"X,",
    ST2","LN2","VRX2"X,",
    ST3","LN3           

This is a concatenation of type 2, by abutting arguments; thus you expected no spaces in ORC. However, the MVS Rexx interpreter handles continued lines by concatenating the two lines and replacing the comma with a space. Thus, it reformatted your statement as
Code:
ORC=ST1","ED1","VRX1"X," ST2","LN2","VRX2"X," ST3","LN3

with spaces as indicated.

The use of an explicit concatenation operator overrides the other two means of concatenation (because when the interpreter find a concat operator, it discards any whitespace to either side), so it gives the desired result.
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Tue Dec 13, 2011 1:07 am
Reply with quote

Thanks a lot for explaining this elaborately.
Back to top
View user's profile Send private message
surbhi jain

New User


Joined: 10 Feb 2012
Posts: 7
Location: INDIA

PostPosted: Wed Feb 22, 2012 1:10 pm
Reply with quote

Hi
I tried using the above concatination technique, but still i am getting error as continuation line missing , i am using it in include condition as below:

Code:
PUSH " INCLUDE COND=("SKEY","LENGTH",CH,"R1",C"STNG"),AND,
                        ("SKEY2",'L2",CH,"R2",C"STNG2")"

In above example i am taking the values of SKEY, LENGTH and all from the pannel and trying to apply search condition based on two conditions and after "AND" i want it to continue the line and take both serach criteria into account.
Can you please let me know how is it possible.

thanks in advance
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 22, 2012 2:13 pm
Reply with quote

each line of a group must be properly terminated
looks like the first one is not...
when concatenating <strings> in a multiline statement it is wiser to use,
across the continuation the explicit concatenation operator
reread and meditate on the answers given and it will be easy to find the glitch

anyway the <string> was badly formatted
try with
Code:
say  " INCLUDE COND=("SKEY","LENGTH",CH,"R1",C'"STNG"'),AND,("SKEY2","LENGTH2",CH,"R2",C'"STNG2"')"


and split on multiple lines according to the rules like

Code:
say  " INCLUDE COND=("SKEY","LENGTH",CH,"R1",C'"STNG"'),AND,(" || ,
                      SKEY2","LENGTH2",CH,"R2",C'"STNG2"')"
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
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
Search our Forums:

Back to Top