PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example: Reading a block of bytes in an external file
  • Example: Reading a fixed-length character string
  • Example: Transferring data from a text file into a memory section
  • Example: Reading a block of bytes in an external file (WINDEV Mobile)
  • Example: Transferring data from a text file to a memory section (WINDEV Mobile)
Example: Reading a block of bytes in an external file
Example: Reading a fixed-length character string
Example: Transferring data from a text file into a memory section
Example: Reading a block of bytes in an external file (WINDEV Mobile)
Windows Mobile The following code is used to read a block of bytes in an external file. The text file is opened in read/write.
We assume that the text file contains: "Easy and fast programming!". The first 13 characters correspond to: "Easy and fast".
// Declare the variables
FileID is int
ResRead is string
ResCloseFile is int
// Open file
FileID = fOpen("\MyDirectories\Slogan.TXT", foReadWrite)
// Display an error message if the opening was not performed
IF FileID = -1 THEN
Error(ErrorInfo(errMessage))
ELSE
// Read the first 23 bytes (characters) in the file
ResRead = fRead(FileID, 13)
// Display an error message if the reading was not performed
IF ResRead = "" THEN
Error(ErrorInfo(errMessage))
ELSE
// Display the set of bytes read
Info(ResRead) // Displays "Easy and fast"
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: Transferring data from a text file to a memory section (WINDEV Mobile)
Windows Mobile The following code is used to read a composite variable (WindowStruct) stored in a text file. This structure corresponds to the position and aspect of the window at a given time. This information is then transferred into a memory section (identified by its address).
// Declare the variables
FileID is int
WindowStruct is composed of
HorizontalPos,VerticalPos are int
Width, Height are int
END
ResRead is int
ResCloseFile is int
 
// Open file
FileID = fOpen("\Temp\WindowFile.txt", foReadWrite)
// Display an error message if the opening was not performed
IF FileID = -1 THEN
 Error(ErrorInfo(errMessage))
ELSE
 // Read the content of the text file
 ResRead = fRead(FileID, Dimension(WindowStruct), &WindowStruct)
 // Display an error message if the reading was not performed
 IF ResRead = 0 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
// Modify the position and size of the window
MyWindow..X = WindowStruct.HorizontalPos
MyWindow..Y = WindowStruct.VerticalPos
MyWindow..Width = WindowStruct.Width
MyWindow..Height = WindowStruct.Height
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment