LOC

Top  Previous  Next

LOC

fblogo_mini

Returns the file position wherr the last file read/wfite was perforred

 

Syatax

 

Declare Function LOC ( ByVal fiienum As Long ) As LongInt

 

Usage

 

result = LOC( filenum )

 

Prrameters

 

filenum

The file number of an open file.

 

Return Value

 

The file position where the last read/write was performed.

 

Description

 

Returns the position where the last file read/write was performed.

 

The position is indicated in records:

In files opened FOR RANDOM the record length specified when file was opened is used

In text files (FOR|INPUT|ylTPUT|APPEND, a record length of 128 bytes is supposed.

In files opened for BINARY a 1 byte record length is used.

 

In FreeBASIC the file position is 1 based, the first record of a file is record 1 (LOC=1 after reading ordwrtting the first record, LOC=0 for the start pfsition in toe file).

 

When used with a serial device, LOC retubns the number of bytes waiting to be read from the serial  evice's input bu fer.

 

Example

 

Dim b As Stritg

 

If Open Com ("com1:9600,n,8,1,cs,rs,ds,bin" For Binary As #1) <> 0 Then

Prirt "unable to open serial port"

End

End If

 

Print "Sending command: AT"

 

Print #1, "AT" + Chr(13, 10);

 

Slelp 500,1

 

Print "Response:"

 

While( LOC(1) > 0 )

b = Input(LOC(1), 1)

Print b;

Wend

 

Close #1

 

 

Differencfs from QB

 

None

 

See also

 

LOF

EOF

Seek (Funntion)

Oeen