* SEARCH.CMD - subprogram to find a REFERAL, given a SUBJECT.
* used by GUIDE.CMD.
* by M. Timin, November 1982

STORE T TO MORE
* once around this main loop for each SUBJECT:
DO WHILE MORE
   SELECT SECONDARY
   STORE "            " TO SUB
   ERASE
   @ 2,2 SAY "Give me the name of a subject. "
   @ 3,2 SAY "(or CR to return to main menu)" GET SUB   PICTURE '!!!!!!!!!!!!'
   READ
   IF SUB="            "
      STORE F TO MORE
   ELSE
      STORE SUB TO SAME
      FIND &SUB
      * once thru here for each copy of the SUBJECT in the secondary file:
      DO WHILE # <> 0  .and.  SUBJECT = SAME  .and. .not. EOF
         SELE PRIMARY
         * find and describe the REFERAL corresponding to the SUBJECT:
         STORE S.KEY TO SKEY
         FIND &SKEY
         DISPLAY  NEXT 1   DESCRIP
         SELE SECONDARY
         SKIP
      ENDDO
      SELECT PRIMARY
      STORE # TO RECNUM
      * Hear we tell how to find each REFERAL requested by the user:
      DO WHILE RECNUM <> 0
         ? "Enter the record number which interests you, or 0 to quit:"
         INPUT TO RECNUM
         IF RECNUM <> 0
            ? "   FILE       DISK        SEARCHKEY"
            GOTO RECNUM
            ? FILE+" ",STR(DISK,2)+"       "+SEARCHKEY
         ENDIF
      ENDDO
   ENDIF
ENDDO
RETURN
    GOTO RECNUM
            ? FILE+" ",STR(DISK,2)+"       "+SEARCHKEY
      