# MX\_FILEVAR

> [HTML Version](mx_filevar.htm)

_Reviewed and revised April 2024_

**xcall MIAMEX, MX\_FILEVAR, op, ch, sts, recno \{,stat\}**

MX\_FILEVAR (MIAMEX 195) gets or sets the value of the file record number variable, and, in the case of ISAM-A, the stats variable.

**Parameters**

_op  _([Num](num.md))  \[in\] 

specifies 0 for get, and 1 for set

_ch  _([Num](num.md))  \[in\] 

is the file channel

_sts_  (Signed [Num](num.md)))  \[out\]

returns 0 for success, -1 if file ch not open, or -2 for unsupported file type

_recno  _([Num](num.md))  \[in/out\]

the value of the record number variable—associated with the file in its OPEN statement—to be retrieved or set.

_stat  _([Num](num.md))  \[in/out\]

the value of the stat variable—associated with the file in its OPEN statement—to be retrieve or set.

**Parameters**

The need for this function arises from the fact that the various file OPEN statements create an internal ink between the file channel and the record number / status variables, which must have global scope. But that complicates the ability to create user defined functions that perform file operations based on the channel number as an argtument.  Either you have to declare those control variable as ++extern inside or any such function, or you can use MX\_FILEVAR to access those control variables. Another approach would be to use the "X" versions of the file i/o statement, which take the control variables as explicit arguments.

**See Also**

•	[File I/O Statements](fileiostatements.md)

•	[XREAD, XWRITE, XUNLOKR](xreadxwritexunlokr.md)

•	[++EXTERN](extern().md)

•	[MX\_FLSET](mx_flset.md)

**History**

2019 July, A-Shell 6.5.1664:  Routine added to A-Shell.