PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example: Transferring data from a HFSQL file to a text file
  • Example: Transferring the content of a composite variable into a text file
  • Example: Transferring data from a HFSQL file to a text file (WINDEV Mobile)
  • Example: Transferring the content of a composite variable into a text file (WINDEV Mobile)
Example: Transferring data from a HFSQL file to a text file
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxJavaPHPAjaxUser code (UMC) The following code is used to write the content of Customer file into a text file. The text file is opened in read/write.
// Declare and initialize the variables
FileNameAndPath is string
FileID is int
SizeWritten is int = 0
ResCloseFile is int

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

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

// Display an error message if the opening was not performed
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 SizeWritten <> -1
// Write the data into the file
SizeWritten = fWrite(FileID, ...
Customer.CustomerLastName + TAB + ...
Customer.CustomerFirstName + TAB + Customer.RealAge + CR)
// Read the next records
HReadNext(Customer, CustomerID)
END
// Display an error message if the writing was not performed
IF SizeWritten = -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
Example: Transferring the content of a composite variable into a text file
WINDEVReports and QueriesUser code (UMC) 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
WindowStruct.HorizontalPos = MyWindow..X
WindowStruct.VerticalPos = MyWindow..Y
WindowStruct.Width = MyWindow..Width
WindowStruct.Height = MyWindow..Height
// Write the position and style of the window into the text file
ResWrite = fWrite(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
Example: Transferring data from a HFSQL file to a text file (WINDEV Mobile)
Windows Mobile The following code is used to write the content of Customer file into a text file. The text file is opened in read/write.
// Declare and initialize the variables
FileNameAndPath is string = "\My Files\File.TXT"
FileID is int
SizeWritten is int = 0
ResCloseFile is int

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

// Display an error message if the opening was not performed
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 SizeWritten <> -1
// Write the data into the file
SizeWritten = fWrite(FileID, ...
Customer.CustomerLastName + TAB + ...
Customer.CustomerFirstName + TAB + Customer.RealAge + CR)
// Read the next records
HReadNext(Customer, CustomerID)
END
// Display an error message if the writing was not performed
IF SizeWritten = -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
Example: Transferring the content of a composite variable into a text file (WINDEV Mobile)
Windows Mobile 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("\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
WindowStruct.HorizontalPos = MyWindow..X
WindowStruct.VerticalPos = MyWindow..Y
WindowStruct.Width = MyWindow..Width
WindowStruct.Height = MyWindow..Height
// Write the position and style of the window into the text file
ResWrite = fWrite(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
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment