****************************************
      * Program name: write.cbl
      * This example demonstrates how to
      * use the WRITE command to create a
      * fixed with file and a comma delimited
      * text file.
      *
      * Copyright 2000 Deskware, Inc.
      ****************************************
      * Syntax: WRITE  TO .
      *
       FD `WRITE1.DAT` RECORD IS 10 BYTES.
       1  filename_var           PIC x(10) value `write2.dat`.
       1  record_size            PIC 99    value 12.
       FD filename_var RECORD IS record_size BYTES.  
       1 write1_record.
           5 write1_field_1      PIC X(05).
           5 write1_field_2      PIC X(05).
       1 write2_record.
           5 write2_field_1      PIC X(05).
           5 write2_field_2      PIC X(05).
       MAIN.
           DISPLAY `This sample program demonstrates how to use the`.
           DISPLAY `WRITE command by creating WRITE1.DAT and WRITE2.DAT.`.
           DISPLAY `Run the program READ.CBL to see an example of how `.
           DISPLAY `to read the data from these two files.`.
           DISPLAY ``.
           PERFORM OPEN_FILES.
           PERFORM CREATE_WRITE_FILE1.
           PERFORM CREATE_WRITE_FILE2.
           PERFORM CLOSE_FILES.
           STOP RUN.
       OPEN_FILES.
           OPEN `WRITE1.DAT` FOR WRITING.
           OPEN filename_var FOR WRITING DELIMITED WITH `,`.
           DISPLAY `FILES OPENED`.
       CREATE_WRITE_FILE1.
           MOVE `12345` TO write1_field_1.
           MOVE `ABCDE` TO write1_field_2.
           WRITE write1_record TO `WRITE1.DAT`.
       CREATE_WRITE_FILE2.
           MOVE `1`     TO write2_field_1.
           MOVE `AB`    TO write2_field_2.
           WRITE write2_record TO filename_var.
       CLOSE_FILES.
           CLOSE `WRITE1.DAT`.
           CLOSE filename_var.
           DISPLAY `FILES CLOSED`.