PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Reading a line in an external file
  • Reading a line in an external file (WINDEV Mobile)
fReadLine (Example)
Reading a line in an external file
WINDEVWEBDEV - Server codeReports and QueriesJavaPHPAjaxUser code (UMC) The following code is used to display the content of a text file in an edit control (EDT_EditFile). Each read operation corresponds to a line of the text file.
// Declare the variables
FileNameAndPath is string
FileID is int
LineRead is string

// Select the file name and path
FileNameAndPath ="C:\MyDirectories\File.txt"
// Open the file
FileID = fOpen(FileNameAndPath)
// Display an error message if the opening was not performed
IF FileID = -1 THEN
Error(ErrorInfo(errMessage))
ELSE
LOOP
// Read the first line of the file
LineRead = fReadLine(FileID)
IF ErrorOccurred THEN
Error(ErrorInfo())
BREAK
END
// End of file?
IF LineRead = EOT THEN BREAK
// Process the row currently read
// Here, add an edit control at the end
EDT_FileContent += [CR] + LineRead
END
// Close the file
fClose(FileID)
ToastDisplay("File reading completed")
END
Reading a line in an external file (WINDEV Mobile)
Windows Mobile The following code is used to display the content of a text file in an edit control (EDT_EditFile). Each read operation corresponds to a line of the text file.
// Declare the variables
FileNameAndPath is string
FileID is int
LineRead is string

// Select the file name and path
FileNameAndPath = "\My Files\File.TXT"
// Open the file
FileID = fOpen(FileNameAndPath)
// Display an error message if the opening was not performed
IF FileID = -1 THEN
Error(ErrorInfo(errMessage))
ELSE
LOOP
// Read the first line of the file
LineRead = fReadLine(FileID)
IF ErrorOccurred THEN
Error(ErrorInfo())
BREAK
END
// End of file?
IF LineRead = EOT THEN BREAK
// Process the row currently read
// Here, add an edit control at the end
EDT_FileContent +=[CR]+ LineRead
END
// Close the file
fClose(FileID)
ToastDisplay("File reading completed")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment