Creating a Comma-delimited ASCII File
March 18, 1996| Author: | David Thompson |
| Date: | March 18th 1996 |
| Category: | Program Code |
| Keywords: | Data export |
| Summary: | A code example to create a "comma delimited" ASCII file for exporting data to other software packages such as Word Processors or Spreadsheets |
This sample illustrates the use of the Acucobol TRAILING extension to the INSPECT verb; the use of the STRING verb and the use of variable length records to create a comma-delimited ASCII file.
*
select mailfile
assign to output "mailfile"
organization is line sequential
access is sequential
file status is f1_status.
*
* specifying minimum & maximum record length forces
* variable length records
*
fd mailfile
record contains 1 to 122.
01 rm_mailrec.
03 filler pic x(122).
*
01 ws_cusrec.
03 ws_custno pic x(6).
03 ws_cusname pic x(30).
03 ws_cusaddr pic x(30).
03 ws_cusadd2 pic x(30).
03 ws_cuscity pic x(20).
03 ws_cusstat pic aa.
03 ws_cuszip pic 9(5).
*
*
procedure division.
*
* first find the end of the data in each field
* and mark it with an asterisk
*
inspect ws_cusname replacing trailing " " by "*".
inspect ws_cusaddr replacing trailing " " by "*".
inspect ws_cusadd2 replacing trailing " " by "*".
inspect ws_cuscity replacing trailing " " by "*".
*
* space fill the destination field
*
move spaces to rm_mailrec.
*
* then STRING all the data fields togther,
* separated by commas, using the asterisk
* to terminate each data field
*
string ws_cusname delimited by "*"
","
ws_cusaddr delimited by "*"
","
ws_cusadd2 delimited by "*"
","
ws_cuscity delimited by "*"
","
ws_cusstat delimited by size
","
ws_cuszip delimited by size into rm_mailrec.
write rm_mailrec.
####
Acucorp, extend and ACUCOBOL are trademarks or registered trademarks of Acucorp, Inc. All rights reserved. All other trademarks are the property of their respective owners.

























