Get_Channel_Size

See Also: File I/O Commands, Direct_Input, Direct_Output, Set_Channel_Position

Purpose

To determine the size (in bytes) of a sequential file currently being used for input or output.

Syntax

Get_Channel_Size {channel-num} To {variable}

Argument Explanation

iChannelNumber A value between 0 and 9, representing the sequential file I/O channel.

variable A variable that is set to the size of the sequential file.

What It Does

This command returns the number of bytes or characters (including line formatting characters, such as carriage return and line-feed) of a sequential file. The specified channel must refer to an open sequential file. Zero is returned if Set_Channel_Size acts on a closed channel.

Example

Integer iCount

Integer iSize

String sBuffer

 

// Create a text file

Direct_output "hello.txt"

 

For iCount From 1 To 10

    Get_Channel_Size 1 To iSize

    Showln "File size of hello.txt is " iSize " bytes."

    Writeln "Line: " iCount " - Hello!"

Loop

 

Get_Channel_Size 1 To iSize

Close_Output

Showln "The size of hello.txt is " iSize

// Error returns 0.

Get_Channel_Size 9 To iSize

Showln "Error channel size is " iSize

// Open file for input.

Direct_Input "hello.txt"

Get_Channel_Size 0 To iSize

Showln "After Direct_Input hello.txt is " iSize " bytes"

Close_Input

Notes