NetWare、Symbian OS、UNIX、Windows、および Windows CE で有効です。
EOF 関数は、ファイルの終わりに到達したかどうかを判別します。
関数の形式
Eof(handle as Integer) as Boolean
ファイル ハンドルを指定します。
この関数は、ファイルの終わりに到達した場合、TRUE を返します。それ以外の場合は、False を返します。
注: 直前の読み取り操作がファイルの終わりに到達した場合、EOF は TRUE を戻します。 この関数は、以降の読み取りコマンドがファイルの終わりに到達したかどうかを前もって確認しません。
例:
この例では、CONFIG.SYS ファイルのバックアップが作成されます。
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.
|
|