Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE
The EOF function determines whether the end of the file has been reached.
Function format:
Eof(handle as Integer) as Boolean
Identifies a file handle.
The function returns TRUE if the end of file has been reached; otherwise, it returns false.
Note: EOF returns TRUE when the last read operation has reached the end of file. The function does not check in advance to see whether a subsequent read command reached the end of a file.
Example:
This example creates a backup of the CONFIG.SYS file.
Dim fIn, fOut as integer ' Declare file handles
Dim OneLine as string ' String to hold one line
Rem First open the Input file...
fIn=OpenFile("C:\CONFIG.SYS",O_READ)
if fIn<0 then
MessageBox("Unable to open input file","Error")
Goto End
End if
Rem ...Then create the output file...
fOut=CreateFile("C:\CONFIG.BAK")
if fOut<0 then
MessageBox("Unable to create output file","Error")
CloseFile(fIn)
Goto End
End if
Rem ...Copy lines until none left...
while Not(Eof(fIn))
if ReadFile(fIn,OneLine) then WriteFile(fOut,OneLine)
wend
Rem ...Close Files, and signal success.
CloseFile(fIn)
CloseFile(fOut)
MsgBox("A backup of the CONFIG.SYS file was created","MyScript",MB_OK)
end:
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|