# MX\_FILEPOS

> [HTML Version](mx_filepos.htm)

_Updated May 2023_

**xcall MIAMEX, MX\_FILEPOS, chan, opcode, pos \{,filidx\}**

MX\_FILEPOS (MIAMEX 118) allows you to get or set the current file position within a sequential file which is open for input or output. 

**Parameters**

_chan_  ([Num](num.md))  \[in\]

should be set to the channel number of the open sequential file.

_opcode_  ([Num](num.md))  \[in\]

0 (mxop\_get) to get the current file position or 1 (mxop\_set) to set it.

_pos_  ([Num](num.md))   \[in/out\]

is the position (offset in bytes from the start of file). For _opcode_ 0 (get), the current position is returned in this parameter. For _opcode_ 1 (set), _pos_ must be set to the desired new file position. Note that to support files larger than 2 GB you must use a variable type capable of it: F6 or I6 or B6.

_filidx_  (B,4)  \[in\]

is an optional handle to a "file index" which can be created and passed back to you by [XTREE](xtree_sbr.md)[xs](keyword-types.md). If _filidx_ is specified and _opcode_ = 1, then rather than setting the file pointer to the byte position specified by _pos_, it instead interprets pos as the desired line number, and uses the index referenced by _filidx_ to locate that line number directly (without having to scan the file sequentially).

If there is an error in the operation, _pos_ will be returned as -1.

**History**

2023 May, A-Shell 6.5.1731.0:  Support extended to files beyond the 32 bit 2GB limit.