View previous topic :: View next topic
|
Author |
Message |
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
I am trying to write a macro for expanding copybooks in COBOL. My cobol copybook contains the comment line -
Code: |
* NNN011 0401 ADDED M&E BAND AND MODEL CODE FOR FUND FILE * |
I am reading the copybook in a stem variable and when I print the stem variable its displaying the &. But when it is inserted by ISREDIT LINE_AFTER in my source code the '&E' are missing. I suspect it is taking it as an AND. I am writing it as a DATALINE. Any suggestions would be of great help.
And output is
Code: |
* NNN011 0401 ADDED M BAND AND MODEL CODE FOR FUND FILE * 16 |
Here is the REXX MACRO part doing the same
Code: |
CALL ALLOCATE_AND_READCPY_RTN
IF (RC = 0 & ERROR_PRESENT = 0) THEN DO
DO I = COPYDATA.0 TO 1 BY -1
'ISREDIT LINE_AFTER .ZCSR = DATALINE "'COPYDATA.I'"'
END |
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
works for me
Code: |
000025 coun = 2
000026 line.1 = "some normal line"
000027 line.2 = "some not normal & line"
000028 do i = 1 to coun
000029 work = line.i
000030 Address ISREDIT "LINE_AFTER .ZLAST = DATALINE (WORK)"
000031 End
000032
|
Code: |
000025 coun = 2
000026 line.1 = "some normal line"
000027 line.2 = "some not normal & line"
000028 do i = 1 to coun
000029 Address ISREDIT "LINE_AFTER .ZLAST = DATALINE '"line.i"' "
000030 End
|
both cases ! |
|
Back to top |
|
|
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
Can u try the specific "M&E" case because the '&' with spaces around was working for me also. Extremely sorry I should have given that information too. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
use the format I showed int the first snippet
Code: |
Address ISREDIT "LINE_AFTER .ZLAST = DATALINE (WORK)" |
in my code I never used anything else |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
& and other characters are hard to play with
i found that i needed to replace them with other characters (with translate),
do the line_after
and then do a edit macro change against the line inserted.
or simply do a change all with label range after the insertion is done.
apostrophies will also eat your lunch.
not at work now, but i used to have a list of char that could be found in cobol copybooks/source code that needed to be changed before the line_after/line_before, then a global change all when finished.
you can create your own list by creating a dummy copybook containing all char and see which give you a problem. |
|
Back to top |
|
|
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
Thanks a lot it worked with the first option you suggested. Though I am unable to understand the reason behind the same. |
|
Back to top |
|
|
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
Hi Dick,
You mean I should translate & and all other special characters that appear in my copybook before writing. And then after they are written replace them with the original ones. In this case what would I translate them into since I do not have choice of letters and numbers which would be appearing in the copybook along with these? |
|
Back to top |
|
|
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
OK got the answer I think you edited your post later. Still its a major problem I would say. Was just curious to know why REXX language producers never corrected it? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
niks_jude wrote: |
OK got the answer I think you edited your post later. Still its a major problem I would say. Was just curious to know why REXX language producers never corrected it? |
It's not a REXX issue, it's an ISPF issue. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
i often used a pound sign: #
the at-sign: @
§ also works.
you can create a macro: called 'chgthis'
/*REXX*/
isredit macro
chg all '@' '&' /* at-sign back to ampersand */
chg all "#" "'" /* pound sign back to apostrophe/quote */
chg all '§' '"' /* § back to double quotes
exit
which you can invoke from your rexx script after you have inserted the lines.
how you go about changing the values in the stem variables is up to you. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
there are probably escape char that you can use,
but never found them,
did not look for them,
used my own method of substitution.
if you have more than 2 or three chars that give you trouble,
you may have to do each variable before the INSERT and then a change all on the line just inserted.
depends on how much garbage is in your copybooks.
that's the fun with writing these neat little tools, they need to be universal. (originally spelled it univeral - almost left if that way)
at my present site, we use endevor, and have 2 legs,
which means i can have copybooks comming from 7 potential libraries
need to have arguements
such as cobol type - batch, cics,
copybook library - unit, systems, acceptance, from 2 different legs and then prod. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
Quote: |
Was just curious to know why REXX language producers never corrected it?
and
It's not a REXX issue, it's an ISPF issue.
|
It is an ISPF feature! Use the SCAN OFF service to turn off the variable substitution.
Though, it is not as 'OFF' as I would have thought.
From the manual:
Quote: |
Because the ISPEXEC call interface for REXX EXECs allows you to specify parameters as symbolic variables, a single scan always takes place before the syntax check of a statement. Therefore, the rule of using two ampersands (&) before variable names to avoid substitution of variable names also applies to REXX EXECs.
|
|
|
Back to top |
|
|
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
Hi Pedro,
Now I feel I can see the reason - When we pass variable in ISREDIT with brackets around it, its not scanned. Thanks.
Dick,
I think I will continue with what Enrico and Pedro have suggested, if still I encounter any problem I will have to go your way. Thanks a lot anyways. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
i use instead of line_before/line_after the ISREDIT COPY macro command nowadays inorder to skip the problem. |
|
Back to top |
|
|
niks_jude Warnings : 1 Active User
Joined: 01 Dec 2006 Posts: 144 Location: Mumbai
|
|
|
|
Thanks can try even that and it is more specific to my need. |
|
Back to top |
|
|
ravikanth
New User
Joined: 12 Jan 2006 Posts: 29
|
|
|
|
Never tried the "SCAN OFF" but does it only work with double ambersand or even single ambersand? Thank you! |
|
Back to top |
|
|
|