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

REXX EDIT MACRO unable to handle double quotes


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anjali.bisht

New User


Joined: 09 Aug 2007
Posts: 7
Location: India

PostPosted: Thu Mar 12, 2015 4:55 pm
Reply with quote

Hello,

I have a requirement where in i need to comment out DISPLAY statements in my COBOL code. I have created a EDIT MACRO for this. My problem is when macro finds a display such as given below

Code:

DISPLAY "THIS IS A TEST"


My macro is unable to handle the double quotes in the display string. See code below

Code:

ISREDIT MACRO
ISREDIT '(LASTLINE) = LINENUM .ZLAST'
DO i = 1 to LASTLINE BY 1
      ISREDIT '(lnh) = LINE 'i
      STRLEN = LENGTH(lnh)
      CODE_LINE = SUBSTR(lnh,1,STRLEN)
      IF SUBSTR(STRIP(CODE_LINE),1,7) = "DISPLAY" THEN
          DO
              CODE_LINE = lnh
              CODE_LINE = OVERLAY('*',CODE_LINE,7)
              ISREDIT 'LINE 'i' = "'CODE_LINE'"'
         END
END





I get error as

Code:

Incomplete string
Put an ending quote at the end of the string.

   Error message ID . : ISRE060



Please help!
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Mar 12, 2015 7:21 pm
Reply with quote

If you substitute the CODE_LINE variable with the actual value, you will see the problem:
Code:
ISREDIT 'LINE 'i' = "'DISPLAY "THIS IS A TEST" '"'


It is a two-step process... rexx substitutes all of the variables before handing it off to the ISPF macro processor. By the time the macro processor sees it, the syntax is wrong.

The problem is that the data and the macro language both use the same characters. In those cases, I usually change all of the double-quotes in the data to something else before doing anything.

Code:
"CHANGE  '7F'x  'A1'x ALL"


And of course, change it back when you are done.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 12, 2015 7:46 pm
Reply with quote

instead of

Code:
ISREDIT 'LINE 'i' = "'CODE_LINE'"'


use

Code:
ISREDIT 'LINE 'i' =  DATALINE(CODE_LINE)'
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Mar 12, 2015 11:32 pm
Reply with quote

Code:
"isredit x all"
"isredit f 'DISPLAY' word first x"
do while rc = 0
  "isredit c p'=' '*' 7 .zcsr .zcsr all"
  "isredit f 'DISPLAY' word next x"
end
Back to top
View user's profile Send private message
anjali.bisht

New User


Joined: 09 Aug 2007
Posts: 7
Location: India

PostPosted: Fri Mar 13, 2015 9:44 am
Reply with quote

Thank you all for your response.

Enrico - I tried with dataline but it is not working. Editor does not identify dataline as a function. icon_eek.gif

Prino - Your solution is good but per my requirement i want a * at 7th position only when DISPLAY is first word in the sentence.

Pedro - I have taken your suggestion and will work on that.

Again thanks for your responses and time.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Mar 13, 2015 10:05 am
Reply with quote

Quote:
I tried with dataline but it is not working. Editor does not identify dataline as a function.


hard to believe ...
search the forum with DATALINE and enrico* as Author

and You will find my TESTED scripts which demonstrate that Your comment is just plain wrong
Back to top
View user's profile Send private message
anjali.bisht

New User


Joined: 09 Aug 2007
Posts: 7
Location: India

PostPosted: Fri Mar 13, 2015 11:54 am
Reply with quote

hi Enrico,

On using DATALINE function as is suggested by you i am getting

Command in error . : LINE 8 = DATALINE(123456* DISPLAY "TEXT TEXT

Too many parameters
Too many parameters specified for the LINE command. Is data quoted?


Error message ID . : ISRE283


I tried following -
Code:

ISREDIT 'LINE 'i' = DATALINE('CODE_LINE')'


With the code provided by you my text gets replaced by DATALINE(CODE_LINE)

Thank you!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Mar 13, 2015 12:32 pm
Reply with quote

this snippet WORKS for me

save it with whatever name in a library in Your "execs" concatenation

before
Code:

 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"
 000005
 000006 Address ISREDIT "macro"
 000007
 000008 data0 = "simple data"
 000009 data1 = "some apost ''''''''"
 000010 data2 = 'some quotes """"""""'
 000011 Address ISREDIT "line_after .zlast = dataline (data0)"
 000012 Address ISREDIT "line_after .zlast = dataline (data1)"
 000013 Address ISREDIT "line_after .zlast = dataline (data2)"
 000014 Exit 0
 ****** **************************** Bottom of Data ****************************


after
Code:

 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"
 000005
 000006 Address ISREDIT "macro"
 000007
 000008 data0 = "simple data"
 000009 data1 = "some apost ''''''''"
 000010 data2 = 'some quotes """"""""'
 000011 Address ISREDIT "line_after .zlast = dataline (data0)"
 000012 Address ISREDIT "line_after .zlast = dataline (data1)"
 000013 Address ISREDIT "line_after .zlast = dataline (data2)"
 000014 Exit 0
 000015
 000016 simple data
 000017 some apost ''''''''
 000018 some quotes """"""""
 ****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Mar 13, 2015 12:44 pm
Reply with quote

icon_redface.gif cut and pasted the wrong examples
( I had forgot that for line substitution no dataline/msgline/noteline is allowed
just the (zzzz) part )

before
Code:

 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"
 000005
 000006 Address ISREDIT "macro"
 000007
 000008 data0 = "simple data"
 000009 data1 = "some apost ''''''''"
 000010 data2 = 'some quotes """"""""'
 000011 Address ISREDIT "line 20 = 'xxxxxxxxxxxxxx'"
 000012
 000013
 000014 Address ISREDIT "line 21 = (data0)"
 000015 Address ISREDIT "line 22 = (data1)"
 000016 Address ISREDIT "line 23 = (data2)"
 000017 Exit 0
 000018
 000019 /*
 000020 some dummy lines
 000021 some dummy lines
 000022 some dummy lines
 000023 some dummy lines
 000024 some dummy lines
 000025 */
 ****** **************************** Bottom of Data ****************************


Code:

 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"
 000005
 000006 Address ISREDIT "macro"
 000007
 000008 data0 = "simple data"
 000009 data1 = "some apost ''''''''"
 000010 data2 = 'some quotes """"""""'
 000011 Address ISREDIT "line 20 = 'xxxxxxxxxxxxxx'"
 000012
 000013
 000014 Address ISREDIT "line 21 = (data0)"
 000015 Address ISREDIT "line 22 = (data1)"
 000016 Address ISREDIT "line 23 = (data2)"
 000017 Exit 0
 000018
 000019 /*
 000020 xxxxxxxxxxxxxx
 000021 simple data
 000022 some apost ''''''''
 000023 some quotes """"""""
 000024 some dummy lines
 000025 */
 ****** **************************** Bottom of Data ****************************


but You could have found Yourself the glitch by looking at the manuals
Back to top
View user's profile Send private message
anjali.bisht

New User


Joined: 09 Aug 2007
Posts: 7
Location: India

PostPosted: Fri Mar 13, 2015 2:40 pm
Reply with quote

Hi Enrico,

Finally dataline worked for me. I used

ADDRESS ISREDIT 'LINE (i) = (loc)'

CODE_LINE was too big variable name. So my final code looks like this

Code:

Address ISREDIT "MACRO"
ISREDIT '(LASTLINE) = LINENUM .ZLAST'
DO i = 1 to LASTLINE BY 1
      ISREDIT '(lnh) = LINE 'i
      STRLEN = LENGTH(lnh)
      LOC = SUBSTR(lnh,8,STRLEN)
      IF SUBSTR(STRIP(LOC,"L"),1,8) = "DISPLAY " THEN
          DO
              LOC = lnh
              LOC = OVERLAY('*',LOC,7)
              Address ISREDIT 'LINE (i) = (LOC)'
         END
END


Thank you so much for your help. You have been far too kind to stick around for this.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Mar 13, 2015 3:31 pm
Reply with quote

here is a more concise way

Code:

 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"
 000005
 000006 Address ISREDIT "macro"
 000007
 000008 comment = "      *"
 000009 Address ISREDIT "(last) = linenum .zlast"
 000010
 000011 do l = 1 to last
 000012     Address ISREDIT "(stmt)  = line (l)"
 000013     stmt = substr(strip(stmt,"T"),8)
 000014     if ( word(stmt,1) = "DISPLAY" ) then ,
 000015         Address ISREDIT "line (l)  = line + (comment) "
 000016 end
 000017
 000018 exit
 000019
 000020 /*
 000021 DISPLAY .....
 000022  DISPLAY .....
 000023   DISPLAY .....
 000024    DISPLAY .....
 000025     DISPLAY .....
 000026      DISPLAY .....
 000027       DISPLAY .....
 000028        DISPLAY .....
 000029         DISPLAY .....
 000030          DISPLAY .....
 000031           DISPLAY .....
 000032            DISPLAY .....
 000033             DISPLAY .....
 000034              DISPLAY .....
 000035               DISPLAY .....
 000036                DISPLAY .....
 000037 */
 ****** **************************** Bottom of Data ****************************
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 -> TSO/ISPF

 


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