Using COBOL COPY/REPLACING in display literals?

2023-05-22 Thread Billy Ashton
Hi guys and gals, I have an odd one that someone asked and I could not 
come up with an answer.


In a COBOL program, using a COPY REPLACING directive, I can see the 
replacement of COBOL procedure statements fine, but when the tag is 
inside of a literal used for a DISPLAY, it is not replaced.


Is this something that can't be done, or is there some special syntax 
for it?


For example, my copy member (FRED) has this (plus a lot more):
If sysin-dflt
   Move  SpacesTo  w-in-:CC:-grp
   Move  '*'   To  w-in-:CC:(1)
   Move  w-set-max To  w-in-:CC:-ct
   Move  'Global Default set for :CC:' To  w-sysin-msg
Else
...

So if I say
Copy FRED Replacing ==:CC:== By ==COMND==

I get this:
If sysin-dflt
   Move  SpacesTo  w-in-COMND-grp
   Move  '*'   To  w-in-COMND(1)
   Move  w-set-max To  w-in-COMND-ct
   Move  'Global Default set for :CC:' To  w-sysin-msg
Else
...

I have looked through the manuals and done my Google diligence, but saw 
nothing about replacements (or lack of) in Procedure Division literals.


Does anyone have a good answer here? Can my programmer do this or not, 
and if so, how?


Thank you and best regards,
Billy Ashton

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Using COBOL COPY/REPLACING in display literals?

2023-05-22 Thread Farley, Peter
Billy,

I do not believe it is possible to use COPY REPLACING to replace text inside a 
literal.  I haven't the time ATM to research the relevant manual citation, but 
I believe the answer is that REPLACING is a COBOL WORD-based search-and-replace 
rather than a simple string search-and-replace, and a literal is a single 
COBOL-word token.

With sufficient quoting you may be able to replace an entire (probably only 
relatively short in practical terms) literal string, but I am not even sure 
that can be done.

I'll look up the manual reference (if there is one, and there may not be) later 
if I can find the time.  Or maybe Tom Ross can pick up on your question and 
provide a more complete answer than mine.

Another solution could be a string-based pre-processing step before a compile 
that does those literal replacements for you instead of asking the compiler to 
do it, but that has its own complexities (like wrapping literals with 
replacements that expand the literal beyond column 72).

Peter

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Billy Ashton
Sent: Monday, May 22, 2023 3:21 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Using COBOL COPY/REPLACING in display literals?

Hi guys and gals, I have an odd one that someone asked and I could not come up 
with an answer.

In a COBOL program, using a COPY REPLACING directive, I can see the replacement 
of COBOL procedure statements fine, but when the tag is inside of a literal 
used for a DISPLAY, it is not replaced.

Is this something that can't be done, or is there some special syntax for it?

For example, my copy member (FRED) has this (plus a lot more):
If sysin-dflt
Move  SpacesTo  w-in-:CC:-grp
Move  '*'   To  w-in-:CC:(1)
Move  w-set-max To  w-in-:CC:-ct
Move  'Global Default set for :CC:' To  w-sysin-msg Else ...

So if I say
Copy FRED Replacing ==:CC:== By ==COMND==

I get this:
If sysin-dflt
Move  SpacesTo  w-in-COMND-grp
Move  '*'   To  w-in-COMND(1)
Move  w-set-max To  w-in-COMND-ct
Move  'Global Default set for :CC:' To  w-sysin-msg Else ...

I have looked through the manuals and done my Google diligence, but saw nothing 
about replacements (or lack of) in Procedure Division literals.

Does anyone have a good answer here? Can my programmer do this or not, and if 
so, how?

Thank you and best regards,
Billy Ashton
--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Using COBOL COPY/REPLACING in display literals?

2023-05-22 Thread Schmitt, Michael
Copy FRED Replacing ==:CC:== By ==COMND==
':CC:' By 'COMND'

Move  SpacesTo  w-in-:CC:-grp
Move  '*'   To  w-in-:CC:(1)
Move  w-set-max To  w-in-:CC:-ct
String 'Global Default Set for '
   ':CC'
   into w-sysin-msg



-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Farley, Peter
Sent: Monday, May 22, 2023 2:43 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Using COBOL COPY/REPLACING in display literals?

Billy,

I do not believe it is possible to use COPY REPLACING to replace text inside a 
literal.  I haven't the time ATM to research the relevant manual citation, but 
I believe the answer is that REPLACING is a COBOL WORD-based search-and-replace 
rather than a simple string search-and-replace, and a literal is a single 
COBOL-word token.

With sufficient quoting you may be able to replace an entire (probably only 
relatively short in practical terms) literal string, but I am not even sure 
that can be done.

I'll look up the manual reference (if there is one, and there may not be) later 
if I can find the time.  Or maybe Tom Ross can pick up on your question and 
provide a more complete answer than mine.

Another solution could be a string-based pre-processing step before a compile 
that does those literal replacements for you instead of asking the compiler to 
do it, but that has its own complexities (like wrapping literals with 
replacements that expand the literal beyond column 72).

Peter

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Billy Ashton
Sent: Monday, May 22, 2023 3:21 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Using COBOL COPY/REPLACING in display literals?

Hi guys and gals, I have an odd one that someone asked and I could not come up 
with an answer.

In a COBOL program, using a COPY REPLACING directive, I can see the replacement 
of COBOL procedure statements fine, but when the tag is inside of a literal 
used for a DISPLAY, it is not replaced.

Is this something that can't be done, or is there some special syntax for it?

For example, my copy member (FRED) has this (plus a lot more):
If sysin-dflt
Move  SpacesTo  w-in-:CC:-grp
Move  '*'   To  w-in-:CC:(1)
Move  w-set-max To  w-in-:CC:-ct
Move  'Global Default set for :CC:' To  w-sysin-msg Else ...

So if I say
Copy FRED Replacing ==:CC:== By ==COMND==

I get this:
If sysin-dflt
Move  SpacesTo  w-in-COMND-grp
Move  '*'   To  w-in-COMND(1)
Move  w-set-max To  w-in-COMND-ct
Move  'Global Default set for :CC:' To  w-sysin-msg Else ...

I have looked through the manuals and done my Google diligence, but saw nothing 
about replacements (or lack of) in Procedure Division literals.

Does anyone have a good answer here? Can my programmer do this or not, and if 
so, how?

Thank you and best regards,
Billy Ashton
--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Using COBOL COPY/REPLACING in display literals?

2023-05-23 Thread Billy Ashton
I was able to use the String command successfully with the replacement. 
Thanks for the direction, Michael!


Thank you and best regards,
Billy Ashton


-- Original Message --

From "Schmitt, Michael" 

To IBM-MAIN@listserv.ua.edu
Date 5/22/2023 3:49:29 PM
Subject Re: Using COBOL COPY/REPLACING in display literals?


Copy FRED Replacing ==:CC:== By ==COMND==
':CC:' By 'COMND'

Move  SpacesTo  w-in-:CC:-grp
Move  '*'   To  w-in-:CC:(1)
Move  w-set-max To  w-in-:CC:-ct
String 'Global Default Set for '
   ':CC'
   into w-sysin-msg



-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Farley, Peter
Sent: Monday, May 22, 2023 2:43 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Using COBOL COPY/REPLACING in display literals?

Billy,

I do not believe it is possible to use COPY REPLACING to replace text inside a 
literal.  I haven't the time ATM to research the relevant manual citation, but 
I believe the answer is that REPLACING is a COBOL WORD-based search-and-replace 
rather than a simple string search-and-replace, and a literal is a single 
COBOL-word token.

With sufficient quoting you may be able to replace an entire (probably only 
relatively short in practical terms) literal string, but I am not even sure 
that can be done.

I'll look up the manual reference (if there is one, and there may not be) later 
if I can find the time.  Or maybe Tom Ross can pick up on your question and 
provide a more complete answer than mine.

Another solution could be a string-based pre-processing step before a compile 
that does those literal replacements for you instead of asking the compiler to 
do it, but that has its own complexities (like wrapping literals with 
replacements that expand the literal beyond column 72).

Peter

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Billy Ashton
Sent: Monday, May 22, 2023 3:21 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Using COBOL COPY/REPLACING in display literals?

Hi guys and gals, I have an odd one that someone asked and I could not come up 
with an answer.

In a COBOL program, using a COPY REPLACING directive, I can see the replacement 
of COBOL procedure statements fine, but when the tag is inside of a literal 
used for a DISPLAY, it is not replaced.

Is this something that can't be done, or is there some special syntax for it?

For example, my copy member (FRED) has this (plus a lot more):
If sysin-dflt
Move  SpacesTo  w-in-:CC:-grp
Move  '*'   To  w-in-:CC:(1)
Move  w-set-max To  w-in-:CC:-ct
Move  'Global Default set for :CC:' To  w-sysin-msg Else ...

So if I say
Copy FRED Replacing ==:CC:== By ==COMND==

I get this:
If sysin-dflt
Move  SpacesTo  w-in-COMND-grp
Move  '*'   To  w-in-COMND(1)
Move  w-set-max To  w-in-COMND-ct
Move  'Global Default set for :CC:' To  w-sysin-msg Else ...

I have looked through the manuals and done my Google diligence, but saw nothing 
about replacements (or lack of) in Procedure Division literals.

Does anyone have a good answer here? Can my programmer do this or not, and if 
so, how?

Thank you and best regards,
Billy Ashton
--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN