Skip to content

Seq_Release_Channel

See Also: File I/O Functions, Seq_New_Channel, Append_Output, Close_Input, Close_Output, Direct_Input, Direct_Output, Sequential File I/O

Purpose

Releases specified sequential input/output (I/O) channel for reuse.

Return Type

Integer

Syntax

Send Seq_Release_Channel {channel-number}

Where:

  • {channel-number} is a valid channel number or an integer variable containing a valid channel number.

Example

Use seq_chnl.pkg
Integer iChannel
Move (Seq_New_Channel()) to iChannel
// ...do some sequential I/O work...
send Seq_Release_Channel iChannel

Use seq_chnl.pkg
Procedure ChannelExample
    Integer iChIn iChOut
    String sFileIn sFileOut sLineIn

    // specify the original (input) file name
    Move "c:\testfile.txt" to sFileIn
    // specify the new (output) file name
    Move "c:\newfile.txt" to sFileOut

    // obtain 2 open channels, 1 for input, 1 for output
    Move (Seq_New_Channel()) to iChIn
    // no channel available
    If (iChIn = DF_SEQ_CHANNEL_NOT_AVAILABLE) begin
        Send Info_Box "No Channel Available for Process" "Error"
        Procedure_Return
    End

    Move (Seq_New_Channel()) to iChOut
    // no channel available
    If (iChOut = DF_SEQ_CHANNEL_NOT_AVAILABLE) begin
        send Info_Box "No Channel Available for Process" "Error"
        // if iChIn contains a valid channel, release it
        If ((iChIn >= DF_SEQ_CHANNEL_MIN) AND (iChIn <= DF_SEQ_CHANNEL_MAX)) ;
            Send Seq_Release_Channel iChIn
        Procedure_Return
    End

    // at this time both iChIn and iChOut contain a valid value
    Direct_Input Channel iChIn sFileIn   // open input channel
    Direct_Output Channel iChOut sFileOut // open output channel

    Repeat
        // read a line from input file
        Readln Channel iChIn sLineIn
        // write the line to output file
        Writeln Channel iChOut sLineIn
    Until (seqeof)  // until sequential end of file

    Close_Input Channel iChIn   // close input channel
    Close_Output Channel iChOut   // close output channel

    // release both channels for reuse
    Send Seq_Release_Channel iChIn
    Send Seq_Release_Channel iChOut
End_Procedure

Notes

  • Valid channel numbers are DF_SEQ_CHANNEL_MIN (0) through DF_SEQ_CHANNEL_MAX (9). Using a different number will not result in an error, but the call is ignored.

  • A channel must be released to be available for reuse for future input/output in the same program.