Previous Topic Next topic Print topic


Example of Setting up a Two-way Pipe

 select i-o-file
     assign to "| cmd /c sort"
     organization is line sequential.
 fd i-o-file.
 01 i-o-file-record pic x(20).
 procedure division.
     open i-o i-o-file
     write i-o-file-record from "Hello world"
     write i-o-file-record from all "A"
     write i-o-file-record from all "Z"
     write i-o-file-record from x"1a"
     perform until exit
         read i-o-file
          at end
             exit perform
         end-read
         display i-o-file-record
     end-perform
     close i-o-file

In this example, the program launches the sort process and passes it three lines of text, followed by an end-of-file marker. It then reads all three lines back from the standard output of the sort process.

Previous Topic Next topic Print topic