*DECK FINDRI
PROC FINDRI ( (INDXPTR),(RECID), INDXORD , SUCCESS );
BEGIN # FINDRI #
*IF DEF,IMS
#
**
*
* 1. PROC NAME AUTHOR DATE
* FINDRI M. D. PICKARD 77/01/28
*
* 2. FUNCTIONAL DESCRIPTION
* FINDRI WILL SEARCH A SUPIO RANDOM FILE INDEX TO FIND AN
* ENTRY ASSOCIATED TO A RECORD IDENT AND PASS BACK IT"S ORDINAL
* TO THE CALLER.
*
* 3. METHOD USED
* IF THERE IS ANY THING IN THE LIST, RECID IS CHECK AGAINST
* THE FIRST AND LAST ENTRY TO SEE IF IT MIGHT BE IN THE
* INDEX. IF IT IS OUTSIDE THE INDEX THEN SUCCESS IS SET FALSE
* AND THE ORDINAL IS SET TO 1 OR LINDX + 1, DEPENDING ON
* WHICH END IT IS OUTSICE OF. OTHERWISE THE INDEX IS SEARCHED
* UNTIL IT IS FOUND OR IT CANT BE FOUND. THE ORDINAL IS SET
* TO THE "HIT" ORDINAL OR THE PLACE WHERE THIS RECID WOULD
* BELONG IN THE INDEX IF IT IS NOT FOUND. SUCCESS IS SET
* APPROPRIATELY.
*
* 4. ENTRY PARAMETERS
* INDXPTR POINTER TO INDEX
* RECID RECORD IDENT TO FIND
*
* 5. EXIT PARAMETERS
* INDEXORD "HIT" ORDINAL, OR WHERE RECID BELONGS
* SUCCESS FOUND/NOT FOUND FLAG
*
* 6. COMDECKS CALLED
* SIOBASE SUPIO BASED ARRAY DEFINITIONS
* SIODEFS SUPIO SYMPL DEFS
*
* 7. ROUTINES CALLED
* NONE.
*
* 8. DAYFILE MESSAGES
* NONE.
#
*ENDIF
CONTROL NOLIST; # STOPS LIST OF SIODEFS AND SIOBASE #
*CALL SIODEFS
*CALL SIOBASE
CONTROL LIST;
ITEM
INDXPTR U, # ADDRESS OF SUPIO INDEX #
RECID U, # RECORD IDENT #
INDXORD U, # INDEX ORDINAL #
SUCCESS B; # FOUND RI SUCCESS FLAG #
ITEM
I U;
P<SIOINDX> = INDXPTR; # FORMAT SUPIO INDEX #
SUCCESS = FALSE; # INITIALIZE SUCCESS INDICATOR #
IF LINDX[0] EQ 0
THEN # THERE ARE NO ENTRIES, THIS RI BELONGS #
INDXORD = 1; # SET RETURN ORDINAL AT ONE#
ELSE
BEGIN # SEE IF IT IS AFTER LAST OR BEFORE FIRST #
IF ( RECID LS RI[1] ) OR ( RECID GR RI[LINDX[0]] )
THEN # TREAT RECID"S BEFORE FIRST AND AFTER #
BEGIN # LAST DIFFERENTLY #
IF RECID LS RI[1]
THEN # IT BELONGS BEFORE ENTRY ONE #
INDXORD = 1; # IT SHOULD BE ENTRY ONE #
ELSE # IT BELONGS AFTER LAST #
INDXORD = LINDX[0] + 1; # GIVE IT LAST INDEX PLUS ONE #
END
ELSE # FIND IT"S PLACE #
BEGIN
INDXORD = 0; # CLEAR INDEX ORDINAL #
FOR I = 1 WHILE ( I LQ LINDX[0] ) AND NOT SUCCESS DO
BEGIN
IF RECID EQ RI[I]
THEN # PLACE IS HERE, FOUND RI #
BEGIN
SUCCESS = TRUE; # FOUND RI INDICATOR #
INDXORD = I; # SET RETURN ORDINAL #
END
ELSE # SHOULD WE GO ANY FURTHER #
BEGIN
IF RECID LS RI[I]
THEN # RI NOT FOUND, BUT IT BELONGS HERE #
BEGIN
INDXORD = I; # SET RETURN ORDINAL #
I = LINDX[0] + 1; # FORCE END OF LOOP #
END
ELSE # BUMP THE INDEX ORDINAL #
I = I + 1;
END
END
END
END
RETURN;
END
TERM # FINDRI #