AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos externos
  • Handling errors
  • Position in the file
  • ANSI/Unicode management
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Reads a line in an external file.
PHP In this version, it is only possible to read lines in external files in ANSI format.
WINDEVWEBDEV - Código ServidorReportes y ConsultasJavaCódigo de Usuario (UMC)PHPAjax
// Open an external file
FileID is int
ResRead is string
FileID = fOpen("C:\MyDirectories\File.txt", foReadWrite)
IF FileID <> -1 THEN
	// Read a line in this file
	ResRead = fReadLine(FileID)
	...
END
WINDEVWEBDEV - Código ServidorReportes y ConsultasJavaCódigo de Usuario (UMC)Ajax
// Open an external file
MyTextFile is DiskFile
ResRead is string
MyTextFile = fOpen("C:\MyDirectories\File.txt", foReadWrite)
IF NOT ErrorOccurred THEN
	// Read a line in this file
	ResRead = fReadLine(MyTextFile)
	...
END
Sintaxis

Reading a file line by line Ocultar los detalles

<Result> = fReadLine(<File used> [, <Separator>])
<Result>: Character string or Unicode character string
  • Line read in an external file.
  • EOT constant if the end of file has been reached.
  • Empty string ("") if an error occurred. In this case, the ErrorOccurred variable is set to True.
Note: A line ends with a carriage return (CR).
PHP This parameter must be a character string.
<File used>: Integer or DiskFile variable
PHP This parameter must be a variant.
<Separator>: Character string
Separator used between the lines. The default separator is the Carriage Return (CR).
PHP This parameter is not available. The separator used is the Carriage return (CR).
WINDEVWEBDEV - Código ServidorReportes y ConsultasiPhone/iPadIOS WidgetJavaCódigo de Usuario (UMC)Ajax

Reading a file line by line using a procedure Ocultar los detalles

<Result> = fReadLine(<File used> , <WLanguage procedure> [, <Separator>])
<Result>: Integer
Number of lines read.
Note: A line ends with a carriage return (CR).
<File used>: Integer or DiskFile variable
PHP This parameter must be a variant.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called for each line read in the file. This procedure is used to manipulate the current line. For more details on this procedure, see Parameters of the procedure used by fReadLine.
<Separator>: Character string
Separator used between the lines. The default separator is the Carriage Return (CR).
PHP This parameter is not available. The separator used is the Carriage return (CR).
Observaciones

Handling errors

fReadLine throws an error in the following cases:
  • the file is not opened,
  • the file is not accessible in read mode,
  • the file is locked by another computer or by another application. fUnlock is used to unlock an external file.

Position in the file

When opening a file, the current position corresponds to:
  • the first file byte (by default),
  • the last byte of the file is the file is opened in "addition" mode (foAdd constant).
This position can be modified by fSeek.
fReadLine reads the specified elements from the current position. Once fReadLine has been executed, the current position is set to the last byte read. fReadLine returns the EOT constant if the end of the file has been reached.
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)Ajax

ANSI/Unicode management

The fReadLine function reads:
  • a Unicode string in a Unicode file.
  • an Ansi string in an Ansi file.
The file is created or opened with fCreate/fOpen by specifying the file type.
Depending on the format of the external file used, some conversions are required once a character string was read in an external file:
Current computer
External file
in ANSI format
(fOpen or fCreate associated with the foAnsi constant)
External file
in Unicode format
(fOpen or fCreate associated with the foUnicode constant)
fReadLine functionPC running WindowsRead operation in ANSI format
Can be converted to Unicode using AnsiToUnicode function
MobileReading in Unicode format
Conversion to ANSI possible with UnicodeToAnsi

Note If the result of the fReadLine function of an ANSI file is assigned to a Unicode string (and vice versa), the conversion will be implicitly performed.
For more details, see Unicode management
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300std.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local