File-Specific Configuration of a Serial Port

You can configure the serial port connection for a specific output file. To do this, set the configuration options in the SELECT … ASSIGN statement for the output file, and specify the options you want in brackets [ ]. For example:

       select output-file
          assign to "com1:[BAUD=9600,TIMEOUT=1000]"
          organization is line sequential.
       fd output-file.
       01 output-file-record pic x(80).
       procedure division.
           open output output-file
           perform 10 times
                write output-file-record from "Hello World!"
           end-perform
           close output-file.

This syntax for setting the options works with .NET managed COBOL only. To preserve compatibility with an unmanaged version of the program, add a $if block around the ASSIGN clause and conditionally compile the program. For example:

       select output-file
      $if ilgen set
          assign to "com1:[BAUD=9600,TIMEOUT=1000]”
      $else
          assign to "com1”
      $end 
          organization is line sequential.
      ...

Related Topics: