I'm a little late to the party, but here's my solution. Yes, the STRING
statement is helpful. I don't advocate using an apostrophe to delimit
nonnumeric literals, preferring to stick with standard COBOL. And yes,
QUOTE is a figurative constant guaranteed to give you a quotation mark.
Here's a sample program:
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. COBTEST.
000610 DATA DIVISION.
000620 WORKING-STORAGE SECTION.
000630 77 ONE-COMMA PIC X VALUE ",".
000640 01 1ST-ITEM PIC X(6) VALUE "ITEM 1".
000650 01 2ND-ITEM PIC X(6) VALUE "ITEM 2".
000660 01 3RD-ITEM PIC X(6) VALUE "ITEM 3".
000670 01 MY-RECORD PIC X(72).
000700 PROCEDURE DIVISION.
000800 1000-START.
000900 INITIALIZE MY-RECORD
001000 STRING QUOTE 1ST-ITEM QUOTE ONE-COMMA
001010 QUOTE 2ND-ITEM QUOTE ONE-COMMA
001011 QUOTE QUOTE ONE-COMMA
001012 QUOTE QUOTE ONE-COMMA
001013 QUOTE 3RD-ITEM QUOTE
001014 DELIMITED SIZE
001015 INTO MY-RECORD
001016 DISPLAY MY-RECORD
001020 STOP RUN.
001100 END PROGRAM COBTEST.
Here's the output:
"ITEM 1","ITEM 2","","","ITEM 3"
Walter
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
Behalf Of Newton, Ernie
Sent: Thursday, September 03, 2015 10:47 AM
To: [log in to unmask]
Subject: [HP3000-L] Fun with COBOL
Greetings,
It's been a long time since I wrote COBOL, and I have an elementary
question about creating a comma-delimited file.
If I want...
"item one", "item two","","","item three"
How do I create the "," between item one and item two? Is it simply PIC
"","" (quote comma quote inside double quotes?)
And the ","",""," would it be the same? Just put that inside double
quotes?
Something tells me that there is an escape sequence, but the mind is not
cooperating.
Thanks,
Ernie
________________________________
This message, including any attachments, is intended solely for the use
of the named recipient(s) and may contain confidential and/or privileged
information. Any unauthorized review, use, disclosure or distribution of
this communication(s) is expressly prohibited. If you are not the
intended recipient, please contact the sender by reply e-mail and
destroy any and all copies of the original message.
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|