I'm trying to replace to beginning of the varibles in a copybook with the replacing option on the copy statement but it does seem to work. What am I doing wrong?
Attached is the copybook and an extract from the program listing. What I was expecting was the first part of varible name to be replaced but it seems that the whole varible has been replaced. The program has a clean compile accept for two warnings about "warning: line not terminated by a newline" at the end of the copybook inclusion.
Although the specification implies either will work.
"Because many of the separators have special significance when processing a COPY statement, the values that can be used for delimiting part of a text word in this way are limited to the parenthesis and colon symbols."
Last edit: Ralph Linkletter 2020-09-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
COPY COPYEXAM REPLACING ":OO:"
BY "SCROO3".
That said, I would have thought that your usage should work !!!
Please always specify version and platform i.e., v3.1 dev-0 and Linux
etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have found a way to make it work byi using the LEADING with the REPLACING. :-)
000038 01 WS-SCR002.
000039 COPY COPYEXAM REPLACING LEADING ==OO== BY ==SCROO2==.
000001C * start of copybook
000002C *
000003C
000004C 02 SCROO2-SCR002-O01 PIC X(9)
000005C VALUE ALL " ".
000006C 02 SCROO2-SCR002-O02 PIC X(50)
000007C VALUE ALL " ".
000008C 02 SCROO2-SCR002-O03 PIC X(100)
000009C VALUE ALL " ".
000010C 02 SCROO2-SCR002-O04 PIC X(100)
000011C VALUE ALL " ".
000012C * end of copybook
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to replace to beginning of the varibles in a copybook with the replacing option on the copy statement but it does seem to work. What am I doing wrong?
Attached is the copybook and an extract from the program listing. What I was expecting was the first part of varible name to be replaced but it seems that the whole varible has been replaced. The program has a clean compile accept for two warnings about "warning: line not terminated by a newline" at the end of the copybook inclusion.
COPYEXAM.CPY is the copybook.
The following is the compiler output.
Last edit: Simon Sobisch 2020-09-26
I would suggest trying "(" and ")" instead of the ":"
The syntax below works as expected.
Although the specification implies either will work.
"Because many of the separators have special significance when processing a COPY statement, the values that can be used for delimiting part of a text word in this way are limited to the parenthesis and colon symbols."
Last edit: Ralph Linkletter 2020-09-26
Works here. But I did re-save the COPYEXAM.CPY with vim after download to get rid of the no terminating new-line warning. VIm adds a final newline.
I'd look to see if any stray unicode / extraneous bytes slipped in to any of the source files.
Cheers,
Blue
did you try putting both in single quotes or double qoutes ?
Last edit: Mickey White 2020-09-26
Following on from Mickey post try doing :
Using quotes gives a syntax error.
Sorry but I'm using GnuCOBOL 3.1-rc1 (30Jun2020) with MinGW binaries
(GCC 6.3.0, PDcurses 4.1.99, GMP 6.2.0, VBISAM 2.0.1)
on win 10.
Hi everyone,
I have found a way to make it work byi using the LEADING with the REPLACING. :-)
000038 01 WS-SCR002.
000039 COPY COPYEXAM REPLACING LEADING ==OO== BY ==SCROO2==.
000001C * start of copybook
000002C *
000003C
000004C 02 SCROO2-SCR002-O01 PIC X(9)
000005C VALUE ALL " ".
000006C 02 SCROO2-SCR002-O02 PIC X(50)
000007C VALUE ALL " ".
000008C 02 SCROO2-SCR002-O03 PIC X(100)
000009C VALUE ALL " ".
000010C 02 SCROO2-SCR002-O04 PIC X(100)
000011C VALUE ALL " ".
000012C * end of copybook