Reviewed and revised May 2024
xcall MIAMEX, MX_NXTCMD, cmdline, status {,flag}
MX_NXTCMD (MIAMEX 18) returns the next line of the current command (.CMD or .DO) file in memory, with an option to preview it without actually consuming it.
Parameters
cmdlineho (String) [out]
should be a string variable long enough to return any expected command line.
status (Integer) [out]
returns zero if there is nothing to input—i.e. no command file is currently running or its end has already been reached—else returns one.
flag (Integer) [in]
if specified and set to a non-zero value, the operation becomes "preview" or "non-destructive read", i.e. the next line is returned in cmdline but the internal command line position is unchanged.
Comments
This function is used in the implementation of GOTO.LIT in order to skip over the command line contents up to the target label. The technique can also be useful in a case where you want to effectively abort a command file execution in response to some data or environmental condition, perhaps chaining to another command file instead.