home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG061.ARC / LIBFIND.CMD < prev    next >
OS/2 REXX Batch file  |  1979-12-31  |  4KB  |  167 lines

  1. *********************************** LIBFIND.CMD
  2. ********** Pull out records with certain subjects.
  3.  
  4. ********** First, ask for sort order.
  5. ERASE
  6. STORE 1 TO ORDER
  7. ?
  8. ? " How do you want references sorted? "
  9. ?
  10. ? "     1. Alphabetically by Author "
  11. ? "     2. Chronologically by Date"
  12. ? "     3. Original Order"
  13.  
  14. @ 9,4 SAY "Enter choice (1-3) " GET ORDER PICT "9"
  15. READ
  16.  
  17. *********** Use appropriate index.
  18. DO CASE
  19.  
  20.    CASE ORDER = 1
  21.         USE LIBRARY INDEX AUTHORS
  22.  
  23.    CASE ORDER = 2
  24.         USE LIBRARY INDEX DATES
  25.  
  26.    CASE ORDER = 3
  27.         USE LIBRARY
  28.  
  29.    OTHERWISE
  30.         RETURN
  31.  
  32. ENDCASE
  33.  
  34. ************************* Next, get search criteria.
  35. ERASE
  36. STORE "                 " TO K1,K2,K3,K4,K5,K6,K7,K8
  37. @ 3,5 SAY "Keyword 1 " GET K1
  38. @ 4,5 SAY "Keyword 2 " GET K2
  39. @ 5,5 SAY "Keyword 3 " GET K3
  40. @ 6,5 SAY "Keyword 4 " GET K4
  41. @ 7,5 SAY "Keyword 5 " GET K5
  42. @ 8,5 SAY "Keyword 6 " GET K6
  43. @ 9,5 SAY "Keyword 7 " GET K7
  44. READ
  45.  
  46. *********************** Count how many keywords to search on.
  47. *********************** and store to the variable kcount.
  48. STORE 0 TO KCOUNT
  49. STORE "1" TO MAC
  50. DO WHILE K&MAC <> " "
  51.    STORE KCOUNT+1 TO KCOUNT
  52.    STORE STR(KCOUNT+1,1) TO MAC
  53. ENDDO
  54.  
  55.  
  56. ************** Now, set up search condition into 
  57. ************** a memory variable called CND.
  58.  
  59. ************** First, set up initial search condition.
  60. STORE CHR(34)+" "+!(TRIM(K1))+","+CHR(34)+" $KEYWORDS" TO CND
  61.  
  62.  
  63. ************** If many keywords to search on,
  64. ************** ask about the logic of the search.
  65. STORE "0" TO LOGIC
  66. IF KCOUNT > 1
  67.    ?
  68.    @ 12,2 SAY " References with 1) ALL keywords or 2) ANY keyword " GET LOGIC
  69.    READ
  70.    IF LOGIC = "1"
  71.       STORE " .AND. " TO LOGIC
  72.    ELSE
  73.       STORE " .OR. " TO LOGIC
  74.    ENDIF (logic=1)
  75.  
  76.    *********** Then finish the 'condition' string (CND).
  77.    STORE 2 TO COUNT
  78.    DO WHILE COUNT <= KCOUNT
  79.       STORE STR(COUNT,1) TO MAC
  80.       STORE CND+LOGIC+CHR(34)+" "+!(trim(K&MAC))+","+CHR(34)+" $KEYWORDS" TO CND
  81.       STORE COUNT+1 TO COUNT
  82.    ENDDO (count <=kcount)
  83.  
  84. ENDIF (kcount > 1)
  85.  
  86. *********** Ask about hardcopy.
  87. ERASE
  88. STORE " " TO LP
  89. @ 5,5 SAY " Send report to printer (Y/N) " GET LP
  90. READ
  91.  
  92. ************ Prepare printer if necessary.
  93. IF !(LP)="Y"
  94.    @ 7,5 SAY "Ready printer, then press any key..."
  95.    WAIT
  96.    SET PRINT ON
  97. ENDIF (LP = Y)
  98.  
  99. ************ Use LF to count line-feeds for formatting
  100. ************ On the screen and printer.
  101. STORE 0 TO LF
  102.  
  103.  
  104. ************ Finally, print the report, listing only
  105. ************ references for whom &CND is true.
  106. ERASE
  107. DO WHILE .NOT. EOF
  108.    IF &CND
  109.       ? "Author:",AUTHOR
  110.       ? "Title :",TITLE
  111.       ? "Pub.  :",PUB
  112.       ? "Date  :",DATE,"        Pages : ",PAGES
  113.       ?
  114.       ? "Keywords : "+KEYWORDS
  115.       ? "Abstract : "
  116.       STORE LF+7 TO LF
  117.       ****************** Break off long abstract at space
  118.       ****************** Nearest the right margin.
  119.       STORE TRIM(ABSTRACT) TO STRING
  120.       STORE LEN(TRIM(STRING)) TO TLEN
  121.       DO WHILE TLEN > 60
  122.          **************** Find space nearest right margin
  123.          STORE 60 TO SPOT
  124.          DO WHILE $(STRING,SPOT,1)<>" "
  125.             STORE SPOT-1 TO SPOT
  126.          ENDDO (while not " ")
  127.          **************** Print sub-string and break off section.
  128.          ? $(STRING,1,SPOT-1)
  129.          STORE LEN(TRIM(STRING))-SPOT TO TLEN
  130.          STORE $(STRING,SPOT+1,TLEN) TO STRING
  131.          STORE LF+1 TO LF
  132.      ENDDO (while len > 60)
  133.      ? STRING
  134.      ?
  135.      ?
  136.      STORE LF+3 TO LF
  137.      ************* Count line feeds, and start on 
  138.      ************* new page, if necessary.
  139.      IF LF >= 55
  140.         EJECT
  141.         STORE 0 TO LF
  142.      ENDIF (lf > 55) 
  143.  
  144.    ENDIF (cnd)
  145.    SKIP
  146. ENDDO (while not eof)
  147.  
  148. SET PRINT OFF
  149. USE
  150. RETURN
  151. d? "
  152. ?
  153. ? "     1. Alphabetically by Author "
  154. ? "     2. Chronologically by Date"
  155. ? "     3. Original Order"
  156.  
  157. @ 9,4 SAY "Enter choice (1-3) " GET ORDER PICT "9"
  158. READ
  159.  
  160. *********** Use appropriate index.
  161. DO CASE
  162.  
  163.    CASE ORDER = 1
  164.         USE LIBRARY INDEX AUTHORS
  165.  
  166.    CASE ORDER = 2
  167.         U