Using explicit I/O Channels

When more than one channel is used for simultaneous input or output then you must explicitly assign separate channel numbers to each file. The following example demonstrates reading data from three files and writing their combined contents to a fourth.

String sCar sBus sTaxi

Direct_Input  Channel 2  "c:\Cars.txt"

Direct_Input  Channel 3  "c:\Busses.txt"

Direct_Input  Channel 4  "c:\Taxis.txt"

Direct_Output Channel 5  "c:\Vehicles.txt"

 

// Read from cars.txt

Repeat

    Readln   Channel 2  sCar

    Writeln  Channel 5  sCar

Until (Seqeof)

 

// Read from busses.txt

Repeat

    Readln   Channel 3  sBus

    Writeln  Channel 5  sBus

Until (Seqeof)

 

// Read from taxis.txt

Repeat

    Readln   Channel 4  sTaxi

    Writeln  Channel 5  sTaxi

Until (Seqeof)

 

Close_Input  Channel 2

Close_Input  Channel 3

Close_Input  Channel 4

Close_Output Channel 5

The (seqeof) expression will return the end-of-file status of the last referenced channel number in a Readln command.