Returns the current position of the cursor in a file, which is the number of bytes from the beginning of the file.
Category: | External File |
Returned data type: | Integer |
Note: | The returned value is an integer representing the current position (offset) from the beginning of the file. |
fileobject.position(<>)
The position method returns the current position of the cursor in a file. Combined with the seekend() method, it can be used to determine the size of a file.
file f
integer byte_size
f.open("C:\filename.txt", "r")
f.seekend(0) // position cursor at end of file
// or if you want to test return codes for the method calls
// boolean rc_ok
// rc_ok = f.open("C:\filename.txt", "r")
// rc_ok = f.seekend(0) // position cursor at end of file
// The integer variable byte_size will have
// the size of the file in bytes
byte_size = f.position()
f.close()