A four byte or six byte unformatted variable. If LINK size is two bytes then XPOS must be at least four bytes; if LINK size is four bytes then XPOS must be six bytes.
XPOS has three separate uses. For opcode 16 it is used internally by INMEMO to keep track of its position between return one logical line (opcode MMO'LIN) calls; for search calls it comes back as zero to indicate pattern not found, else non-zero; for all other calls it is used to return error status (0 if ok, 1 if the memo file filled up, -1 if an illegal link was encountered, and all other codes refer to the corresponding AMOSL file service system error numbers.) Refer to the standard INMEMO include file, MMOSYM.BSI for symbol names for these errors; also see the EXTCTL: Extended options parameter for more information about error reporting.
You should map this variable in your program on an even boundary, preferably as follows:
MAP1 XPOS,X,4 ! (2 byte LINK)
MAP1 POS,B,4,@XPOS
or
MAP1 XPOS,X,6 ! (2 or 4 byte LINK)
MAP1 POS,B,4,@XPOS
The variable POS is used with four byte LINKs to provide numeric access to XPOS (maximum binary size is 5 bytes). The XCALL INMEMO statement will specify XPOS, but other references to XPOS in the BASIC program will be via POS. For the two-byte LINKs, the secondary variable POS serves no purpose other than to make the variable usage for the two versions identical (thus simplifying the examples). A suggested mapping that will work for both link sizes is provided in the standard INMEMO include file, MMOPAR.BSI.
POS (first four bytes of XPOS) must be all null (zero) for the initial return 1 logical line call for each memo pad. (BASIC will do this for you when your program starts and INMEMO will take care of it from there so you don't need to ever actually set it to zero.)
For search calls, the calling program has to check POS to determine the outcome of the search.
For return-one-line calls you have to check the value of POS on return to determine if the TEXT returned is valid. If the TEXT is valid, POS will be set non-zero. If there were no more comments to retrieve, POS will be returned as zero (leaving it ready to retrieve the next memo pad.)
For all opcodes involving editing, POS is returned as zero if all was ok, -1 (MMO'LKE) if an illegal link was encountered, 1 (MMO'FUL) if the file filled up before all of the memo could be written, and any other AMOSL file service system error code to indicate other errors. You must follow all edit calls with a test similar to the following:
XCALL INMEMO,...
IF POS <> 0 CALL INMEMO'ERROR
The error routine should distinguish among the various classes of errors:
INMEMO'ERROR:
IF POS = MMO'LKE CALL ILLEGAL'LINK'ERROR
IF POS = MMO'FUL CALL MEMO'FILE'FULL
PRINT "ERROR #";POS;"IN INMEMO"
The symbols MMO'LKE and MMO'FUL are defined in the MMOSYM.BSI ++include file and should be used instead of the numbers.