CFile:ReadBswap CFile:Write

CFile:Seek


The Seek method sets the byte offset of the file read/write position. Three starting point options are provided as enumerated values: eBegin, eCurrent, and eEnd.

Syntax

nPos = CFile:Seek( nBytes, nFromWhere )

bullet.gif    nBytes is the distance to move the file pointer.

bullet.gif    nFromWhere specifies the position from which to move (see Remarks).

bullet.gif    On success, bSuccess returns nPos, the byte offset of the file position.

bullet.gif    On failure, this method returns -1.

Remarks

The nFromWhere argument has 3 possible values that specify the reference point from which to offset the file pointer. You can specify the reference point using predefined CFile member names or you can use the numeric values listed in the table below. Note that the CFile Member values are specified using the particular instance of the class, such as F, and not the class name CFile. In addition, a dot is used, not a colon, to separate the class instance name and the member name. For example, if a CFile instance is named F, then use F.eBegin. Alternatively, you can use the value 0, which means the same thing. However, using the value 0 makes the script less "user friendly".

Values of the nFromWhere Parameter

CFile Member

Value

Reference Position

eBegin

0

Beginning of file

eCurrent

1

Current position

eEnd

2

End of file

Example

Suppose a CFile F exists and that the file pointer is at byte offset 54. The following script advance the file writing position to byte offset 80:

Printf("pos = %d", F:FilePos() )

-- result: pos = 54

F:Seek( 26, F.nCurrent )

-- advance the file position by 26 bytes

Printf("pos = %d", F:FilePos() )

-- result: pos = 80

Related Topics

CFile class, FilePos


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.