FEOF
Check whether the end of a file has been reached.
WebVue support - Yes.
Before using any of the file management instructions, except FSTAT, RENAME, UNLINK, FILETOBUF or BUFTOFILE, you must first open the file using an FOPEN instruction.
Before any program including the FOPEN instruction ends, it must execute an FCLOSE instruction.
Syntax
IntVal = FEOF(Filename);
Return type: INTEGER.
Argument |
Meaning |
Filename |
The name of the file to be checked. Type STR. |
Execution
FEOF returns zero if the reading functions (like FGETS or FGETC) have not reached the end of the named file.
The function FEOF does not move the file pointer on reading. Consequently, the following loop will travel through the file one time too many and L will be (NULL) on the last line. The test for the end of file should directly follow the read (FGETS) instruction.
WHILE(FEOF(filename) == 0)
L = FGETS(filename,80);
PRINT(L);
WEND
Example
A control structure of the type DO{......}WHILE(CONDITION) is not available within SCADA BASIC, however, the following construct provides the same functionality:
eof = 0;
WHILE(eof == 0)
L = FGETS(filename,80);
eof = FEOF(filename);
IF(eof == 0) THEN
PRINT(L);
END IF
WEND