ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE


  • Closing a file opened several times
  • Closing a locked file
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Closes an external file.
WEBDEV - Server codePHPAjax
// Open an external file
FileID is int
ResClose is int
FileID = fOpen("C:\MyDirectories\File.txt", foReadWrite)
IF FileID <> -1 THEN
...
// Close the external file
ResClose = fClose(FileID)
END
New in version 28
WEBDEV - Server codeAjax
ResClose is int
 
// Open an external file
MyFile is DiskFile
MyFile = fOpen("C:\MyDirectories\File.txt", foReadWrite)
IF NOT ErrorOccurred THEN
...
// Close the external file
ResClose = fClose(MyFile)
END
Syntax
<Result> = fClose(<File used>)
<Result>: Integer
  • 0 is the external file is closed,
  • -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant. fClose throws an error if the file is not opened.
<File used>: Integer or DiskFile variable
PHP This parameter must be a variant.
Remarks

Closing a file opened several times

The same file can be opened several times simultaneously. Each version of the file must be closed individually via its own identifier.
WEBDEV - Server codeAjax

Closing a locked file

A blocked file will be automatically unblocked when you close it.
Reminder: fLock is used to lock an external file. fUnlock is used to unlock an external file.
Business / UI classification: Business Logic
Component: wd280std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo ReadFile
PROCEDURE ReadFile(ArquivoTxt is string, TipoUnicodeToAnsi is string)

//Le arquivo texto
INFO(TIMESYS())

// Declare the variables
PathFile is string = ArquivoTxt
IdFile, ResCloseFile, FileID, NumeroLinha is int
Line is string

NextTitle("Atencao")

IF fFileExist(ArquivoTxt) = true

// Open the file
FileID = fOpen(PathFile,foReadWrite)
IF IdFile = -1 THEN
Error(ErrorInfo(errMessage))
ELSE

if TipoAnsiUnicode = "UnicodeToAnsi"
//Converte de Unicode para Ansi
Line = UnicodeToAnsi(fReadLine(FileID))
else
Line = fReadLine(FileID)
end

//Linha 1
NumeroLinha = 1
/// ----COLOQUE AQUI O PROGRESS BAR = 1
//Info("Linha:" + NumeroLinha, Line) ///----------------- LINHA LIDA
//Inclua aqui a SUB Procedure de importacao dos dados

WHILE Line <> EOT AND Line <> ""

//Proxima linha
NumeroLinha += 1
/// ----COLOQUE AQUI O PROGRESS BAR + 1
Line = fReadLine(FileID)
//Info("Linha:" + NumeroLinha, Line) ///----------------- LINHA LIDA
//Inclua aqui a SUB Procedure de importacao dos dados
END
IF Line = "" THEN Error(ErrorInfo(errMessage))
IF Line = EOT THEN Info("Final do Arquivo.")
ResCloseFile = fClose(IdFile)
IF ResCloseFile = -1 THEN
//Error(ErrorInfo(errMessage))
END

END

ELSE
Info("Arquivo não encontrado!")
END

info(NumeroLinha,TIMESYS())
adrianoboller
21 Feb. 2015