compile Insert RTI_MVBFS_SERVER_PLUGIN_QM_SOURCE

/*
* This insert contains the source for a program to install on the QM server
* The program will support efficient record selection
*/
#UNDEFINE _IGNORE_THE_FOLLOWING_
#IFDEF _IGNORE_THE_FOLLOWING_
SUBROUTINE RTI_MVBFS_SERVER_PLUGIN_QM( METHOD, COMMANDS, ACTIVELIST, UNIQUEID, RESULTS)
*
*
* THIS SUBROUTINE IS USED FOR EXECUTING A CHAIN OF QUERIES ON QM, RETURNING THE KEYS TO OI
* SEE RTI_CHAIN_SELECT.
*
* 03/24/19   rjc  Created from D3 version
* **********************************

* Selectinfo equates
EQU SL$ACTIVE TO 1

EQU TRUE TO 1, FALSE TO 0
EQU AM TO CHAR(254), VM TO CHAR(253), SVM TO CHAR(252), FM TO CHAR(254)

LISTID = 'RTI_SERVER_SELECT_':UNIQUEID

* Did they pass in some keys?
* If so, make an active select list
IF ACTIVELIST NE "" THEN
   FORMLIST ACTIVELIST
END


*
* Run the commands
*
EXEC.ERR = ""
RESULTS = ""

CMD_CNT = DCOUNT(COMMANDS, AM)

FOR WHICH_COMMAND = 1 TO CMD_CNT

    CMD = COMMANDS<WHICH_COMMAND>

    CONTINUE = ( CMD # "" ) AND ( WHICH_COMMAND = 1  OR  SELECTINFO(0,SL$ACTIVE)  = 1 ) 
     IF CONTINUE THEN
         EXECUTE CMD
     END

NEXT WHICH_COMMAND

 IF ( SELECTINFO(0,SL$ACTIVE)  = 1 ) THEN

	DONE = 0
    I = 0
	LOOP
		READNEXT ID ELSE DONE = 1
	UNTIL DONE
	   		I = I + 1
	  	 	RESULTS<I> = ID
	REPEAT

END    

RETURN
END
#ENDIF
