User Tools

Site Tools


cdc:nos2.source:nam5871:findri

FINDRI

Table Of Contents

  • [00002] PROC FINDRI ( (INDXPTR),(RECID), INDXORD , SUCCESS )

Source Code

FINDRI.txt
  1. *DECK FINDRI
  2. PROC FINDRI ( (INDXPTR),(RECID), INDXORD , SUCCESS );
  3. BEGIN # FINDRI #
  4. *IF DEF,IMS
  5. #
  6. **
  7. *
  8. * 1. PROC NAME AUTHOR DATE
  9. * FINDRI M. D. PICKARD 77/01/28
  10. *
  11. * 2. FUNCTIONAL DESCRIPTION
  12. * FINDRI WILL SEARCH A SUPIO RANDOM FILE INDEX TO FIND AN
  13. * ENTRY ASSOCIATED TO A RECORD IDENT AND PASS BACK IT"S ORDINAL
  14. * TO THE CALLER.
  15. *
  16. * 3. METHOD USED
  17. * IF THERE IS ANY THING IN THE LIST, RECID IS CHECK AGAINST
  18. * THE FIRST AND LAST ENTRY TO SEE IF IT MIGHT BE IN THE
  19. * INDEX. IF IT IS OUTSIDE THE INDEX THEN SUCCESS IS SET FALSE
  20. * AND THE ORDINAL IS SET TO 1 OR LINDX + 1, DEPENDING ON
  21. * WHICH END IT IS OUTSICE OF. OTHERWISE THE INDEX IS SEARCHED
  22. * UNTIL IT IS FOUND OR IT CANT BE FOUND. THE ORDINAL IS SET
  23. * TO THE "HIT" ORDINAL OR THE PLACE WHERE THIS RECID WOULD
  24. * BELONG IN THE INDEX IF IT IS NOT FOUND. SUCCESS IS SET
  25. * APPROPRIATELY.
  26. *
  27. * 4. ENTRY PARAMETERS
  28. * INDXPTR POINTER TO INDEX
  29. * RECID RECORD IDENT TO FIND
  30. *
  31. * 5. EXIT PARAMETERS
  32. * INDEXORD "HIT" ORDINAL, OR WHERE RECID BELONGS
  33. * SUCCESS FOUND/NOT FOUND FLAG
  34. *
  35. * 6. COMDECKS CALLED
  36. * SIOBASE SUPIO BASED ARRAY DEFINITIONS
  37. * SIODEFS SUPIO SYMPL DEFS
  38. *
  39. * 7. ROUTINES CALLED
  40. * NONE.
  41. *
  42. * 8. DAYFILE MESSAGES
  43. * NONE.
  44.  #
  45. *ENDIF
  46. CONTROL NOLIST; # STOPS LIST OF SIODEFS AND SIOBASE #
  47. *CALL SIODEFS
  48. *CALL SIOBASE
  49. CONTROL LIST;
  50. ITEM
  51. INDXPTR U, # ADDRESS OF SUPIO INDEX #
  52. RECID U, # RECORD IDENT #
  53. INDXORD U, # INDEX ORDINAL #
  54. SUCCESS B; # FOUND RI SUCCESS FLAG #
  55. ITEM
  56. I U;
  57. P<SIOINDX> = INDXPTR; # FORMAT SUPIO INDEX #
  58. SUCCESS = FALSE; # INITIALIZE SUCCESS INDICATOR #
  59. IF LINDX[0] EQ 0
  60. THEN # THERE ARE NO ENTRIES, THIS RI BELONGS #
  61. INDXORD = 1; # SET RETURN ORDINAL AT ONE#
  62. ELSE
  63. BEGIN # SEE IF IT IS AFTER LAST OR BEFORE FIRST #
  64. IF ( RECID LS RI[1] ) OR ( RECID GR RI[LINDX[0]] )
  65. THEN # TREAT RECID"S BEFORE FIRST AND AFTER #
  66. BEGIN # LAST DIFFERENTLY #
  67. IF RECID LS RI[1]
  68. THEN # IT BELONGS BEFORE ENTRY ONE #
  69. INDXORD = 1; # IT SHOULD BE ENTRY ONE #
  70. ELSE # IT BELONGS AFTER LAST #
  71. INDXORD = LINDX[0] + 1; # GIVE IT LAST INDEX PLUS ONE #
  72. END
  73. ELSE # FIND IT"S PLACE #
  74. BEGIN
  75. INDXORD = 0; # CLEAR INDEX ORDINAL #
  76. FOR I = 1 WHILE ( I LQ LINDX[0] ) AND NOT SUCCESS DO
  77. BEGIN
  78. IF RECID EQ RI[I]
  79. THEN # PLACE IS HERE, FOUND RI #
  80. BEGIN
  81. SUCCESS = TRUE; # FOUND RI INDICATOR #
  82. INDXORD = I; # SET RETURN ORDINAL #
  83. END
  84. ELSE # SHOULD WE GO ANY FURTHER #
  85. BEGIN
  86. IF RECID LS RI[I]
  87. THEN # RI NOT FOUND, BUT IT BELONGS HERE #
  88. BEGIN
  89. INDXORD = I; # SET RETURN ORDINAL #
  90. I = LINDX[0] + 1; # FORCE END OF LOOP #
  91. END
  92. ELSE # BUMP THE INDEX ORDINAL #
  93. I = I + 1;
  94. END
  95. END
  96. END
  97. END
  98. RETURN;
  99. END
  100. TERM # FINDRI #
cdc/nos2.source/nam5871/findri.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator