FOpen
Function FOpen( file index, filename )
Returns a non-zero value on successfully opening filename on index file index.
Syntax IF FOPEN( 1,"Test.Txt" ) THEN PRINT "Test.txt is open on file index 1"
Remarks
file index is a number that will be the handle by which the file is accessed during the time that it remains open.
If filename does not exist, a zero length file will be created.
If filename does exist, it will be opened as a text file and the file pointer will be placed at the beginning of the file.
If filename exists, but is locked,or opened by another program, FOpen will return false (zero).
If file index is already in use, from a previous call to FOpen, a runtime error will occur.
See Also:
FClose FCloseAll FileExists File and Directory functions
Example Script
STRING a = "*.txt"
a = FINDFIRST(a)
WHILE LEN(a)
FOPEN(1,a) ' Open the file on index 1
a = FINDNEXT()
WHILE NOT FEOF(1) ' print the contents of each matching file.
PRINT FGETS(1)
WEND
FCLOSE(1)
WEND
Script Output
(your results may be different)
IF CHDIR("C:\Temp") THEN
PRINT CWD()
ELSE
PRINT "Directory not found."
ENDIF
NUMBER i,j
' let's print the ASCII chart (this might get messy).
FOR i = 0 TO 15
FOR j = 0 TO 15
PRINT CHR(i * 15 + j);
NEXT
NEXT