PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example: Retrieving the current position in an external file
  • Example: Modifying the current position in an external file
  • Example: Positioning in an external file from the end of file
  • Example: Retrieving the current position in an external file (WEBDEV)
  • Example: Modifying the current position in an external file (WEBDEV)
Example: Retrieving the current position in an external file
Example: Modifying the current position in an external file
Example: Positioning in an external file from the end of file
Example: Retrieving the current position in an external file (WEBDEV)
WEBDEV - Server codePHPAjax The following code is used to retrieve the current position in an external file after reading a block of bytes. The text file is opened in read/write.
// Declare the variables
FileNameAndPath is string
FileID is int
ResRead is string
ResPosition is int
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 the opening was not performed
IF FileID = -1 THEN
Error(ErrorInfo(errMessage))
ELSE
// Read the first 1000 bytes in the file
ResRead = fRead(FileID, 1000)
// Display an error message if the reading was not performed
IF ResRead = "" THEN
Error(ErrorInfo(errMessage))
ELSE
// Current position?
ResPosition = fSeek(FileID, 0, fpCurrent)
  // Display the position of the pointer
  IF ResPosition <> -1 THEN
Info("The current position is: " + ResPosition)
  ELSE
// Display the error message if a problem occurred with fSeek
  Error(ErrorInfo(errMessage))
  END
END
// 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: Modifying the current position in an external file (WEBDEV)
WEBDEV - Server codePHPAjax The following code is used to write a character string from the current position. The text file is opened in read/write.
// Declare the variables
FileNameAndPath is string
FileID is int
ResPosition is int
SizeWritten is int
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 the opening was not performed
IF FileID = -1 THEN
Error(ErrorInfo(errMessage))
ELSE
// Position on byte 150
ResPosition = fSeek(FileID, 150, fpBeginning)
IF ResPosition = -1 THEN
// Display an error message if the positioning was not performed
Error(ErrorInfo(errMessage))
ELSE
// Write the character string from the current position
SizeWritten = fWrite(FileID, "Sales progression")
// Display an error message if the writing was not performed
IF SizeWritten = -1 THEN Error(ErrorInfo(errMessage))
END
// 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