# MX\_READJCB
> [HTML Version](mx_read_write_jcb.htm)
_Reorganized April 2024_
**xcall MIAMEX, MX\_READJCB, jobno, buffer \{,lokflg \{,status\}\}**
**xcall MIAMEX, MX\_WRITEJCB, jobno, buffer \{,lokflg \{,status\}\}**
MX\_READJDB (MIAMEX 73) reads a job control block or record from jobtbl.sys, and MX\_WRITEJCB (MIAMEX 74) writes a jobtbl record.
**Parameters**
_jobno_ ([Num](num.htm.md))
the job number of the block to read. This is equivalent to the record number, starting at 1 for the first job. _jobno_ 0 refers to the control record, which should not be accessed.
_buffer_
the record buffer to receive the data. For _jobno_ 0 (header), the buffer should be mapped per the JCB'HDR map statements in [JOBTBL.MAP in SOSLIB:\[907,16\]](https://bitbucket.org/microsabio/soslib/src/master/907016/jobtbl.map) or as an instance of the ST\_JCBHDR defstruct in [JOBTBL.SDF in SOSLIB:\[907,16\]](https://bitbucket.org/microsabio/soslib/src/master/907016/jobtbl.sdf). For all other _jobno_ values (individual job table records), _buffer_ should be mapped per the JCB'REC map statements in [JOBTBL.MAP in SOSLIB:\[907,16\]](https://bitbucket.org/microsabio/soslib/src/master/907016/jobtbl.map) or as an instance of the ST\_JCBREC defstruct in [JOBTBL.SDF in SOSLIB:\[907,16\]](https://bitbucket.org/microsabio/soslib/src/master/907016/jobtbl.sdf).
For relevant symbol definitions, see [JOBTBL.DEF in SOSLIB:\[907,16\]](https://bitbucket.org/microsabio/soslib/src/master/907016/jobtbl.def).
_lokflg_ ([Num](num.htm.md))
may optionally be set to 1 to lock the record prior to reading it (leaving it locked thereafter). To unlock it you would then need to write the record back, using MX\_WRITEJCB, and also specifying the same _lokflg_=1.
_status_ ([Num](num.htm.md)) \[out\]
returns 0 for success, else an error code
**Comments**
To scan all of the job table records, start at JOBNO=1 and keep incrementing it, skipping records with JCB'JOBTYP = JOBTYP'FREE, and quitting when you hit a record with JCB'JOBTYP = JOBTYP'EOF.
As is hopefully obvious, MX\_READJDB should used with extreme caution, since writing invalid information to jobtbl.sys could cause undesirable results.
**History**
2023 December, A-Shell 1753: Add current SBX name to the job control block, taking the last ten bytes from the end of the message field