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
  • Operating mode in Windows Vista (and later)
  • 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
Writes a line to an external file. The characters required to go to the next line are automatically inserted at the end of the added line.
PHP Only the ANSI format is supported.
WINDEVWEBDEV - Código ServidorReportes y ConsultasJavaCódigo de Usuario (UMC)PHPAjax
// Open an external file
FileID is int
ResWrite is boolean
FileID = fOpen("C:\MyDirectories\File.txt", foReadWrite)
IF FileID <> -1 THEN
	// Write a line to this file
	ResWrite = fWriteLine(FileID, "Meeting report")
	IF ResWrite = False THEN
		...
	END
END
WINDEVWEBDEV - Código ServidorReportes y ConsultasJavaCódigo de Usuario (UMC)Ajax
// Open an external file
MyTextFile is DiskFile
ResWrite is boolean
IF fOpen(MyTextFile, "C:\MyDirectories\File.txt", foReadWrite) = True THEN
	// Write a line to this file
	ResWrite = fWriteLine(MyTextFile, "Meeting report")
	IF ResWrite = False THEN
		...
	END
END
Sintaxis

Writing a line to an external file Ocultar los detalles

<Result> = fWriteLine(<File used> , <Line to write>)
<Result>: Boolean
  • True if the write operation was performed to the specified file,
  • False if an error occurs. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: Integer or DiskFile variable
PHP This parameter must be a variant.
<Line to write>: Character string
Line to be written to the file (up to 2GB).
WINDEVWEBDEV - Código ServidorReportes y ConsultasAndroidWidget Android JavaCódigo de Usuario (UMC)Ajax

Writing a fixed-length line to an external file (speeds up the write operation) Ocultar los detalles

<Result> = fWriteLine(<File used> , <Address of line to write> , <Size to write>)
<Result>: Boolean
  • True if the write operation was performed to the specified file,
  • False if an error occurs. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: Integer or DiskFile variable
<Address of line to write>: Address
Address of the line to be written to the file.
<Size to write>: Integer
Size in bytes (characters) of the line that must be written (up to 2GB).
This parameter must be less than or equal to the real size of the wine written to the external file. For example, if the size of the line to write is equal to 100 bytes, <Size to write> must be less than or equal to 100 bytes.
If this parameter is less than the real size of the written line, only the specified number of bytes will be written to the text file. The line will be truncated.
Observaciones

Handling errors

fWriteLine throws an error in the following cases:
  • the file is not opened,
  • the file is not accessible in write mode,
  • the file is locked by another computer or by another application,
  • no disk space is available.
Attention The function fWriteLine function can only be used on text files. This function does not support the binary 0 (the write operation is stopped).
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)

Operating mode in Windows Vista (and later)

If this function does not work properly in Windows Vista (and later), check whether the file or directory used is not in one of the system directories (Windows directory or "Program Files" directory).
In Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have administrator privileges to handle and/or modify the files or directories in system directories (Windows directory or "Program Files" directory).
Programming tip: If you need to manipulate / modify files or directories, without needing administrator privileges, it is advisable:
  • avoid writing to the Windows directory or to the "Program Files" directory,
  • use the system directory of the application (returned by SysDir with the srAppDataCommun constant, for example).
Remark: Under Windows Vista (and higher), the virtualization mechanism makes applications Vista-compatible.. If the file is created in a system directory without having sufficient rights, this file will actually be created in another directory (C:\Users\<LOGIN>AppData\Local\VirtualStore\Windows\). In this case, the file cannot be shared between several applications.

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.
fWriteLine writes the specified elements from the current position. Once fWriteLine has been executed, the current position is set to the last byte written.

ANSI / Unicode management

fWriteLine is used to write:
  • 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.
Remarks:
  • The size to be written to a Unicode file must be multiplied by two compared to an ANSI file.
  • If an ANSI character string is written to a Unicode file (and vice versa), the conversion is implicitly performed.
    Format of the string passed as parameter
    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)
    fWriteLine functionANSINo conversion is required before the write operationAutomatic conversion of the string before the write operation
    UnicodeAutomatic conversion of the string before the write operationNo conversion is required before the write operation
In WINDEV and WEBDEV projects, if the "Use ANSI strings at runtime" option is enabled in the project configuration description, the default opening mode is foAnsi (1st column).
In WINDEV and WEBDEV projects, if the "Use UNICODE strings at runtime" option is enabled in the project configuration description, the default opening mode is foUnicode (second column).
In the WINDEV Mobile projects, regardless of the version and mode, the opening mode used by default is foUnicode (second column).
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: 27/03/2025

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