FREEFILE

Action

Returns a free Filenumber.

 

Syntax

bFileNumber = FreeFile()

 

Remarks

bFileNumber

(Byte) Free Filenumber, which can be used for opening next file

 

This function gives you a free filenumber, which can be used for file ?opening statements. In contrast to QB this file numbers start with 128 and goes up to 255. Use range 1 to 127 for user defined filenumbers to avoid filenumber conflicts with the systemnumbers from FreeFile()

This function is implemented for compatility with QB.

 

 

ASM

Calls

_GetFreeFileNumber

 

Input

none

 

Output

r24: Filenumber

r25: Errorcode

 

C-Flag: Set on Error

 

    

 

Example

Ff = Freefile() ' get file handle
Open "test.txt" For Input As #ff ' we can use a constant for the file too
Print Lof(#ff) ; " length of file"
Print Fileattr(#ff) ; " file mode" ' should be 1 for input
Do
Line Input #ff , S ' read a line
' line input is used to read a line of text from a file
Print S ' print on terminal emulator
Loop Until Eof(ff) <> 0
'The EOF() function returns a non-zero number when the end of the file is reached
'This way we know that there is no more data we can read
Close #ff