FGets
Function FGETS( file index )
Returns a string from the file. FGETS reads until it hits a newline character or until a max of 8192 bytes.
Syntax a = FGETS( 1 )
Remarks
file index is the index to a file previously opened by a successful call to FOpen .
FGETS is very similar to the 'C' language function of the same name.
FGETS will read until it finds a newline (ASCII value 10), or until it reaches the maximum it will read which is 8 kilobytes.
If the file represented by file index is at end-of-file, FGETS will return an empty string.
If you attempt to read a binary file using FGETS, it is likely that you will get unexpected or invalid results from FGETS.
See Also:
FGetc FPuts File and Directory functions
Example Script
NUMBER x = 1
STRING a = "*.txt"
a = FINDFIRST(a)
WHILE LEN(a)
FOPEN(x,a) ' x contains 1 on the first pass
a = FINDNEXT()
WHILE NOT FEOF(x) ' print the contents of each matching file.
PRINT FGETS(x)
WEND
FCLOSE(x)
WEND
Script Output
(your results may be different, again we printed out a script file.)
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