Xbasic
FILE.SEEK Function
Syntax
V file_pointer.Seek(N Position)
Arguments
- PositionNumeric
The position in the file to start reading data.
Description
Set the position in the file.
Discussion
The .SEEK() method sets the position of the file pointer to a Byte Offset (measured in bytes) in relation to the beginning of the file specified by the file object pointer. This function is used to read and write data at a particular location in a data file.
Example
This script will change four characters in the Defaults file. The old text "VAR3" will be changed to the new text "XXXX".
file_pointer = FILE.open("c:\a5\defaults.txt", FILE_RW_SHARED)
Read the third group of 4 characters.
file_pointer.seek(8) text = file_pointer.read(4) trace.writeln("Old value: " + text)
Write the four characters at the same position.
file_pointer.seek(8) file_pointer.write("XXXX")
Read the third group of 4 characters to see the change.
file_pointer.seek(8) text = file_pointer.read(4) trace.writeln("New value: " + text) file_pointer.close()
See Also