Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE
The CloseFile function closes the file associated with a file handle obtained from a call to OpenFile or CreateFile.
This file content function has the format:
CloseFile(handle as Integer) as Boolean
File handle obtained from a call of OpenFile or CreateFile.
On successful completion, the function returns TRUE (non-zero). If the function fails (for example, when the handle is not the handle of a valid open file) the function returns FALSE.
Example: CloseFile function
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
' 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
' ...Then create the output file...
fOut=CreateFile("C:\CONFIG.BAK")
if fOut<0 then
MessageBox("Unable to create output file","Error")
Goto End
End if
' ...Copy lines until none left...
while Not(Eof(fIn))
if ReadFile(fIn,OneLine) then WriteFile(fOut,OneLine)
wend
' ...Close Files, and signal success.
CloseFile(fIn)
CloseFile(fOut)
MessageBox("A backup of the CONFIG.SYS file was created","MyScript")
end:
|
Copyright © 2013 CA.
All rights reserved.
|
|