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
fWriteLine (Example)
WINDEV Example: Transferring data from an HFSQL data file to a text file (WINDEV)
The following code is used to write the content of Customer file into a text file. Each record corresponds to a line in the text file. The text file is opened in read/write.
// Declare and initialize the variables
FileNameAndPath is string
FileID is int
ResWrite is boolean = True
ResCloseFile is int

// Select the file name and path
FileNameAndPath = "C:\MyDirectories\File.txt"

// Open file
FileID = fOpen(FileNameAndPath, foReadWrite)

// Display an error message if no file was opened
IF FileID = -1 THEN
	Error(ErrorInfo(errMessage))
ELSE
	// Read the first record
	HReadFirst(Customer, CustomerID)
	// More records to read? Write error?
	WHILE HOut = False AND ResWrite = True
		// Write the records line by line into the text file
		ResWrite = fWriteLine(FileID, ...
			Customer.CustomerLastName + TAB + ...
			Customer.CustomerFirstName + TAB + Customer.CustomerAge)
		// Read the next records
		HReadNext(Customer, CustomerID)
	END
	// Display an error message if the writing was not performed
	IF ResWrite = False THEN Error(ErrorInfo(errMessage))
	// Close the file
	ResCloseFile = fClose(FileID)
	IF ResCloseFile = -1 THEN
		// Display an error message if the closing was not performed
		Error(ErrorInfo(errMessage))
	END
END
WINDEV Example: Transferring the content of a composite variable into a text file (WINDEV)
The following code is used to retrieve the position and style of a window at a given time. This information is stored in a composite variable (WindowStruct). Then, the content of the composite variable is transferred (by address) into a text file.
// Declare the variables
FileID is int
WindowStruct is composed of
HorizontalPos, VerticalPos are int
Width, Height are int
END
ResWrite is int
ResCloseFile is int
 
// Create a file
FileID = fCreate("C:\Temp\WindowFile.txt")
 
// Display an error message if the creation was not performed
IF FileID = -1 THEN
Error(ErrorInfo(errMessage))
ELSE
// Retrieve the position and style of the window
WindowStructHorizontalPos = MyWindow.X
WindowStructVerticalPos = MyWindow.Y
WindowStructWidth = MyWindow.Width
WindowStructHeight = MyWindow.Height
// Write the position and style of the window into the text file
ResWrite = fWriteLine(FileID, &WindowStruct, Dimension(WindowStruct))
// Display an error message if the writing was not performed
IF ResWrite = -1 THEN Error(ErrorInfo(errMessage))
// Close the file
ResCloseFile = fClose(FileID)
IF ResCloseFile = -1 THEN
// Display an error message if the closing was not performed
Error(ErrorInfo(errMessage))
END
END
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