home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / WNDTOOL5.ZIP / TAGLIST.SUB < prev    next >
Text File  |  1989-04-26  |  29KB  |  837 lines

  1. '
  2. '$PAGE
  3. '
  4. '******************************************************************************
  5. '                    Function :                                               *
  6. '                                                                             *
  7. ' Purpose:                                                                    *
  8. '                                                                             *
  9. '                                                                             *
  10. ' Results:                                                                    *
  11. '                                                                             *
  12. ' Usage  :                                                                    *
  13. '                                                                             *
  14. '                                                                             *
  15. ' Date Written : 01/01/89 - Date Tested: 01/01/89 - Author: James P Morgan    *
  16. ' Date Modified:          -            :          -       :                   *
  17. '-----------------------------------------------------------------------------*
  18. ' NOTE:                                                                       *
  19. '******************************************************************************
  20. '                                                                             *
  21. '     SUB PROGRAM NAME          (PARAMETERS)                 STATIC/RECURSIVE *
  22. '-----------------------------------------------------------------------------*
  23. '                                                                             *
  24. '============================================================================
  25. '
  26. SUB    TAGLIST(HEADER$,SHOWITEMS%,MAXITEMS%,NUMTAGGED%,ITEM$(1),TAGITEMS%(1),FORE%,BACK%,HFORE%,HBACK%,QUADRANT$,SHADOW%) STATIC
  27.  
  28.        DEFINT A-Z                               'make all short intergers by default
  29.  
  30.        SELECT.BASE=1                            'normalize
  31.  
  32.        TEMP.ITEM$=STRING$(255," ")
  33.        ITEM.MIN=LBOUND(ITEM$)                   'adjust for callers OPTION BASE
  34.        TAGITEMS.MIN=LBOUND(TAGITEMS%)
  35.  
  36.        BEGVAL=1
  37.  
  38.        MENU.TOP.ROW=0
  39.        MENU.TOP.LEFT.COL=0
  40.        MENU.BOTTOM.ROW=0
  41.        MENU.BOTTOM.RIGHT.COL=0
  42.  
  43.        BUTTONS%=0                               'assume no mouse support avail
  44.  
  45.        CALL MMCHECK(BUTTONS%)                   'see if mouse support avail
  46.  
  47.        GOSUB TAGLIST.MMCURSORON
  48.  
  49.        MOUSECOL=0                               'locate the mouse cursor in upper
  50.        MOUSEROW=0                               'left top corner of screen
  51.  
  52.        CALL MMSETLOC(MOUSECOL,MOUSEROW)         'move the mouse cursor
  53.  
  54.        GOSUB TAGLIST.MMCURSOROFF
  55.  
  56.        IF SHOWITEMS% > MAXITEMS% THEN           'we cant show more than whats avail
  57.            SHOWITEMS%=MAXITEMS%
  58.        ENDIF
  59.  
  60.        MAX.NUMTAGGED.ALLOWED=MAXITEMS%          'assume we can tag all the items
  61.  
  62.        IF NUMTAGGED%>0 THEN                     'can we tag all the items?
  63.           MAX.NUMTAGGED.ALLOWED=NUMTAGGED%      'no, only this many can be tagged
  64.           NUMTAGGED%=0
  65.        ENDIF
  66.  
  67. '
  68.        WINDLEN=LEN(HEADER$)                     'assume window length is header length
  69.  
  70. 'Determine width of window from length of items
  71.        J.BASE=1
  72.        FOR J=J.BASE TO MAXITEMS%
  73.            J.SUB=(J-J.BASE)+ITEM.MIN
  74.            IF LEN(ITEM$(J.SUB)) > WINDLEN THEN
  75.                 WINDLEN=LEN(ITEM$(J.SUB))
  76.            ENDIF
  77.  
  78.        NEXT
  79.  
  80. 'If Quadrant is in ROW:COL format, extract Row and Column
  81.  
  82.        IF INSTR(QUADRANT$,":")<>0 THEN          'was an absolute row:column specified
  83.              GOSUB TAGLIST.GETORD
  84.           GOTO TAGLIST.GO1
  85.        ENDIF
  86.  
  87. 'Determine Position based on Quadrant Parameter and size of menu
  88.  
  89.        QUADRANT=VAL(QUADRANT$)                  'The window is to be in 1 of the 5 quadrants
  90.  
  91.        IF QUADRANT <0 OR QUADRANT >4 THEN       'make sure the quadrant is valid
  92.            QUADRANT=0                           'if invalid, default to center of screen
  93.        ENDIF
  94.  
  95.        CALL SETQUAD(QUADRANT,CROW,CCOL,WINDLEN,SHOWITEMS%)
  96.  
  97.        ULR=CROW-((SHOWITEMS%+2)/2-.5)           'the upper left row:column window co-ordinates
  98.        ULC=CCOL-((WINDLEN/2)-.5)
  99.        LRR=ULR+SHOWITEMS%+1                     'the lower right window co-ordinates
  100.        LRC=ULC+WINDLEN-1
  101.  
  102. '
  103. 'Create Window for List
  104. TAGLIST.GO1:
  105.        MENU.TOP.ROW=ULR+2                       'allow for the menu name box above the window
  106.        MENU.TOP.LEFT.COL=ULC
  107.        MENU.BOTTOM.ROW=LRR
  108.        MENU.BOTTOM.RIGHT.COL=LRC
  109.  
  110.        FRAME%=4
  111.  
  112.        CALL MAKEWIND(ULR,ULC,LRR,LRC,FRAME,FORE%,BACK%,GROW,SHADOW%,LABEL$)
  113.  
  114.        TEMPHDR$=SPACE$(WINDLEN)                 'make menu header as big as biggest item
  115.  
  116.        IF LEN(HEADER$)<>WINDLEN THEN            'does the menu header need centering?
  117.             GOSUB TAGLIST.PUTHDR                'YES
  118.        ENDIF
  119.  
  120.        ATTR=(HBACK% AND 7)*16+HFORE%            'display the menu header
  121.        ROW=ULR
  122.        COL=ULC
  123.        CALL FASTPRT(HEADER$,ROW,COL,ATTR)
  124.  
  125.        ATTR=(BACK% AND 7)*16+FORE%              'bracket the menu header in the window
  126.        ROW=ULR+1
  127.        COL=ULC
  128.        DAT$=STRING$(WINDLEN,205)
  129.        CALL FASTPRT(DAT$,ROW,COL,ATTR)
  130.  
  131. 'Set current choice to List Item #1, Set Beginning and Ending values,
  132. 'Display 'More...' message and enter Loop
  133.  
  134.        NUMTAGGED%=0                             'startoff assuming no items tagged
  135.  
  136.        SELECT.%=1                               'display the first group of items
  137.  
  138.        BEGVAL=1                                 'starting with the first item
  139.        ENDVAL=SHOWITEMS%                        'and ending with the max we can display at once
  140.  
  141.        GOSUB TAGLIST.FILL
  142.  
  143. '
  144. TAGLIST.LOOP:
  145.        GOSUB TAGLIST.PRESS                          'Get KeyPress
  146.  
  147.        IF KP$=CHR$(13) OR KP$=CHR$(27) THEN         'was Enter or ESC key pressed?
  148.            GOTO TAGLIST.DONE                        'yes, were are thru
  149.        ENDIF
  150.  
  151.        GOTO TAGLIST.LOOP                            'keep waiting for user to press a key
  152.  
  153. '
  154. 'Check for KeyPress and sound error if not UP ARROW, DOWN ARROW, HOME, END, PAGE UP, PAGE DOWN, or RETURN
  155. TAGLIST.PRESS:
  156.        GOSUB TAGLIST.MMCURSORON
  157.  
  158.        CALL MMGETLOC(MOUSECOL,MOUSEROW)
  159.  
  160.        CALL MMCLICK(LFT%,RGT%)                       'flush any mouse clicks
  161.  
  162.        GOSUB TAGLIST.GET.PRESS
  163.  
  164.        IF KP$="" THEN                                'wait for a key or mouse click
  165.            GOTO TAGLIST.PRESS
  166.        ENDIF
  167.  
  168. '
  169. ' Was a INS or DEL key pressed
  170. '
  171.        IF LEN(KP$)=2 THEN                            'was an extended function key pressed?
  172.           IF MID$(KP$,2,1)=CHR$(82) OR MID$(KP$,2,1)=CHR$(83) THEN
  173.              GOTO TAGLIST.PRESS.ON
  174.           ELSE
  175.              GOTO TAGLIST.DOWN                       'see if cursor down pressed
  176.           ENDIF
  177.        ENDIF
  178.  
  179. TAGLIST.PRESS.ON:
  180.        IF KP$=CHR$(13) THEN                          'Enter key pressed?
  181.            RETURN
  182.        ENDIF
  183.  
  184.        IF KP$=CHR$(27) THEN                          'ESC key pressed
  185.            NUMTAGGED%=-1                             'nothing noted as being selected
  186.          RETURN
  187.        ENDIF
  188.  
  189.        SELECT.SUB=(SELECT.%-SELECT.BASE)+TAGITEMS.MIN
  190.  
  191.        IF LEN(KP$)<>2 THEN                           'was an extened function key pressed?
  192.            GOTO TAGLIST.PRESS.CONT                   'no
  193.        ENDIF
  194.  
  195.        KP$=RIGHT$(KP$,1)                             'get the function key code pressed
  196.  
  197. '
  198. ' Check if INS key pressed and we are allowed to tag anymore items
  199. '
  200.        IF ((KP$=CHR$(82)) AND (TAGITEMS%(SELECT.SUB)=0)) THEN
  201.           IF NUMTAGGED+1<=MAX.NUMTAGGED.ALLOWED THEN
  202.                  TAGITEMS%(SELECT.SUB)=1             'tag this item
  203.                  NUMTAGGED%=NUMTAGGED%+1             'we have 1 more item tagged
  204.                  GOSUB TAGLIST.FILL                  'turn on the tag flag for this displayed item
  205.               GOTO TAGLIST.PRESS
  206.           ELSE
  207.               GOTO TAGLIST.PRESS.SOUNDOFF            'let user know this one already tagged
  208.           ENDIF
  209.        ENDIF
  210.  
  211. '
  212. ' Check if DEL key pressed and if this item is tagged
  213. '
  214.        IF ((KP$=CHR$(83)) AND (TAGITEMS%(SELECT.SUB)=1)) THEN
  215.              TAGITEMS%(SELECT.SUB)=0                 'untagg this item
  216.              NUMTAGGED%=NUMTAGGED%-1                 'we now have 1 less items tagged
  217.              GOSUB TAGLIST.FILL                      'turn off the tag flag on the displayed item
  218.           GOTO TAGLIST.PRESS
  219.        ENDIF
  220.  
  221.        GOTO TAGLIST.PRESS.SOUNDOFF                    'an error/problem,so let user know
  222.  
  223. TAGLIST.PRESS.CONT:
  224.        GOSUB TAGLIST.FIND.OPTION                      'find the first char of an item that matches key pressed
  225.  
  226.        IF SELECT.%<>SAVE.SELECT THEN                  'was a new item found?
  227.            RETURN                                     'YES
  228.        ENDIF
  229.  
  230. TAGLIST.PRESS.SOUNDOFF:
  231.        GOSUB TAGLIST.SOUNDOFF                         'NO, a new item not found!
  232.        GOTO TAGLIST.PRESS
  233.  
  234. '
  235. 'Process DOWN ARROW KeyPress
  236. TAGLIST.DOWN:
  237.        IF ASC(RIGHT$(KP$,1))=80 THEN                 'was cursor down key pressed?
  238.            OLD=SELECT.%                              'this is the current item highlighted
  239.            SELECT.%=SELECT.%+1                       'this is the new item we want highlighted
  240.        ELSE
  241.            GOTO TAGLIST.UP                           'NO, see if cursor up
  242.        ENDIF
  243.  
  244.        IF SELECT.% > MAXITEMS% THEN                  'are we at the end of the items?
  245.            SELECT.% = MAXITEMS%                      'cant go past the end of the items
  246.            GOSUB TAGLIST.SOUNDOFF
  247.        ENDIF
  248.  
  249.        IF (SELECT.% > ENDVAL) AND (SELECT.% = MAXITEMS%) THEN
  250.            BEGVAL=BEGVAL+1
  251.            ENDVAL=ENDVAL+1
  252.            GOSUB TAGLIST.FILL
  253.          RETURN
  254.        ENDIF
  255.  
  256. '
  257. ' have we requested an item on the next screen of items
  258. '
  259.        IF (SELECT.% > ENDVAL) AND (SELECT.% <> MAXITEMS%) THEN
  260.            BEGVAL=BEGVAL+1
  261.            ENDVAL=ENDVAL+1
  262.            GOSUB TAGLIST.FILL
  263.          RETURN
  264.        ENDIF
  265.  
  266. '
  267. ' highlight the next item
  268.        GOSUB TAGLIST.FILL
  269.        RETURN
  270.  
  271. '
  272. 'Process UP ARROW KeyPress
  273. TAGLIST.UP:
  274.        IF ASC(RIGHT$(KP$,1))=72 THEN                 'was cursor up key pressed?
  275.            OLD=SELECT.%                              'this is the current item highlighted
  276.            SELECT.%=SELECT.%-1                       'this is the new item we want highlighted
  277.        ELSE
  278.            GOTO TAGLIST.PG.UP                        'NO, see if page up
  279.        ENDIF
  280.  
  281.        IF SELECT.% < 1 THEN                          'are we at the top of the items?
  282.            SELECT.%=1                                'cant go past the top
  283.            GOSUB TAGLIST.SOUNDOFF
  284.        ENDIF
  285.  
  286.        IF (SELECT.% < BEGVAL) AND (SELECT.% = 1) THEN
  287.            BEGVAL=BEGVAL-1
  288.            ENDVAL=ENDVAL-1
  289.            GOSUB TAGLIST.FILL
  290.          RETURN
  291.        ENDIF
  292.  
  293. '
  294. ' have we requested an item on the next screen of items
  295. '
  296.        IF (SELECT.% < BEGVAL) AND (SELECT.% <> 1) THEN
  297.            BEGVAL=BEGVAL-1
  298.            ENDVAL=ENDVAL-1
  299.            GOSUB TAGLIST.FILL
  300.          RETURN
  301.        ENDIF
  302.  
  303. '
  304. ' highlight the next item
  305.        GOSUB TAGLIST.FILL
  306.        RETURN
  307.  
  308. '
  309. 'Process PAGE UP KeyPress
  310. TAGLIST.PG.UP:
  311.        IF ASC(RIGHT$(KP$,1))=73 THEN                 'was page up  key pressed?
  312.            OLD=SELECT.%                              'this is the current item highlighted
  313.            SELECT.%=SELECT.%-SHOWITEMS%              'this is the new item we want highlighted
  314.        ELSE
  315.            GOTO TAGLIST.PG.DN                        'NO, see if cursor down
  316.        ENDIF
  317.  
  318.        IF SELECT.% < 1 THEN                          'are we at the first screen of items?
  319.            KP$=CHR$(0)+CHR$(79)                      'simulate a END key press
  320.            SELECT.%=OLD
  321.          GOTO TAGLIST.ENDK
  322.        ENDIF
  323.  
  324.        BEGVAL=BEGVAL-SHOWITEMS%                      'calculate the first and last items in next screen
  325.        ENDVAL=ENDVAL-SHOWITEMS%
  326.  
  327.        IF BEGVAL < 1 THEN                            'we cant go past first item
  328.            BEGVAL=1                                  'point to first item
  329.            ENDVAL=SHOWITEMS%
  330.        ENDIF
  331.  
  332.        GOSUB TAGLIST.FILL                            'highlight the item
  333.        RETURN
  334.  
  335. 'Process PAGE DOWN KeyPress
  336. TAGLIST.PG.DN:
  337.        IF ASC(RIGHT$(KP$,1))=81 THEN                 'was page down  key pressed?
  338.            OLD=SELECT.%                              'this is the current item highlighted
  339.            SELECT.%=SELECT.%+SHOWITEMS%              'this is the new item we want highlighted
  340.        ELSE
  341.            GOTO TAGLIST.HOME                         'NO, see if home pressed
  342.        ENDIF
  343.  
  344.        IF SELECT.% > MAXITEMS% THEN                  'are we at the last screen of items?
  345.            KP$=CHR$(0)+CHR$(71)                      'simulate a HOME key press
  346.            SELECT.%=OLD
  347.          GOTO TAGLIST.HOME
  348.        ENDIF
  349.  
  350.        BEGVAL=BEGVAL+SHOWITEMS%                      'calculate the first and last items in next screen
  351.        ENDVAL=ENDVAL+SHOWITEMS%
  352.  
  353.        IF ENDVAL > MAXITEMS% THEN                    'we cant go past the last item
  354.            ENDVAL=MAXITEMS%                          'point to last item
  355.            BEGVAL=ENDVAL-SHOWITEMS%+1
  356.        ENDIF
  357.  
  358.        GOSUB TAGLIST.FILL                            'highlight the item
  359.        RETURN
  360.  
  361. '
  362. 'Process HOME KeyPress
  363. TAGLIST.HOME:
  364.        IF ASC(RIGHT$(KP$,1))=71 THEN                 'was home key pressed?
  365.            OLD=SELECT.%                              'this is the current item highlighted
  366.            SELECT.%=1                                'display the first group of items
  367.        ELSE
  368.            GOTO TAGLIST.ENDK                         'NO, see if end key pressed
  369.        ENDIF
  370.  
  371.        BEGVAL=1                                      'point to the first item
  372.        ENDVAL=BEGVAL+SHOWITEMS%-1                    'and display the first screen of this many items
  373.        GOSUB TAGLIST.FILL
  374.        RETURN
  375.  
  376. '
  377. 'Process END KeyPress
  378. TAGLIST.ENDK:
  379.        IF ASC(RIGHT$(KP$,1))=79 THEN                 'was end key pressed?
  380.            OLD=SELECT.%                              'this is the current item highlighted
  381.            SELECT.%=MAXITEMS%                        'display the last group of items
  382.        ELSE
  383.            GOTO TAGLIST.ERRCHK                       'NO, let user know invalid key pressed
  384.        ENDIF
  385.  
  386.        ENDVAL=MAXITEMS%                              'point to the last item
  387.        BEGVAL=ENDVAL-SHOWITEMS%+1                    'display screen of last group of items
  388.  
  389.        GOSUB TAGLIST.FILL
  390.        RETURN
  391.  
  392. '
  393. 'Process ERROR
  394. TAGLIST.ERRCHK:
  395.        GOSUB TAGLIST.SOUNDOFF                        'let user know problem/error
  396.        GOTO TAGLIST.PRESS
  397.  
  398. '
  399. 'Fill Contents of window
  400. TAGLIST.FILL:
  401.        IF BEGVAL < 1 THEN                             'make sure we dont go out of bounds
  402.            BEGVAL=1
  403.        ENDIF
  404.  
  405.        IF ENDVAL > MAXITEMS% THEN                     'make sure we dont go past the end of the items
  406.            ENDVAL=MAXITEMS%
  407.        ENDIF
  408.  
  409.        OFFSET=ENDVAL-SELECT.%
  410.  
  411.        IF OFFSET < 0 THEN
  412.            OFFSET = 0
  413.        ELSEIF OFFSET > SHOWITEMS%-1 THEN
  414.            OFFSET = SHOWITEMS%-1
  415.        ENDIF
  416.  
  417.        GOSUB TAGLIST.MMCURSOROFF
  418.  
  419.        K=1
  420.        J.BASE=1
  421.  
  422. '
  423. ' display the group of items we need
  424. '
  425.        FOR J=BEGVAL TO ENDVAL
  426.          ATTR=(BACK% AND 7)*16+FORE%
  427.          ROW=(ULR+1+K)
  428.          COL=ULC
  429.          J.SUB=(J-J.BASE)+ITEM.MIN
  430.          J.SUB2=(J-J.BASE)+TAGITEMS.MIN
  431.  
  432.          IF TAGITEMS%(J.SUB2)=1 THEN
  433.              MID$(ITEM$(J.SUB),2,1)=CHR$(16)
  434.          ELSE
  435.              MID$(ITEM$(J.SUB),2,1)=" "
  436.          ENDIF
  437.  
  438.          DAT$=ITEM$(J.SUB)
  439.          CALL FASTPRT(DAT$,ROW,COL,ATTR)
  440.  
  441.          K=K+1
  442.        NEXT
  443.  
  444. '
  445. 'highlight the next item displayed
  446.        ATTR=(FORE% AND 7)*16+BACK%
  447.  
  448.        IF BEGVAL=1 AND SELECT.%=1 THEN
  449.             ROW=ULR+2
  450.        ELSEIF (SELECT.% >= BEGVAL) AND (SELECT.% <= ENDVAL) THEN
  451.             ROW=ULR+2+SELECT.%
  452.        ENDIF
  453.  
  454.        IF (ENDVAL=MAXITEMS%) AND (SELECT.%=MAXITEMS%) THEN
  455.             ROW=LRR
  456.        ELSE
  457.             ROW=LRR-OFFSET
  458.        ENDIF
  459.  
  460.        COL=ULC
  461.        SELECT.SUB=(SELECT.%-SELECT.BASE)+ITEM.MIN
  462.  
  463.        IF TAGITEMS%(SELECT.SUB)=1 THEN
  464.            MID$(ITEM$(SELECT.SUB),2,1)=CHR$(16)
  465.        ELSE
  466.            MID$(ITEM$(SELECT.SUB),2,1)=" "
  467.        ENDIF
  468.  
  469. '
  470. ' display this selected item, and highlight it
  471.        DAT$=ITEM$(SELECT.SUB)
  472.        CALL FASTPRT(DAT$,ROW,COL,ATTR)
  473.  
  474.        MOUSEROW=(ROW-1)*8                   'if so, put the mouse cursor on the new selection
  475.        MOUSECOL=(COL+(LEN(DAT$)\2)-1)*8
  476.        CALL MMSETLOC(MOUSECOL,MOUSEROW)
  477.  
  478.        GOSUB TAGLIST.MORE                   'put arrows on top and bottom of window
  479.        RETURN
  480.  
  481. '
  482. 'Display arrowhead on top or bottom of window as necessary
  483. TAGLIST.MORE:
  484.        IF SHOWITEMS%=MAXITEMS% THEN         'are we doing POPMENU
  485.             RETURN                          'yes, all items displayed at once
  486.        ENDIF
  487.  
  488.        MCOL=ULC%+((LRC-ULC%)/2)-3           'calculate the windows upper frame location
  489.  
  490.        DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
  491.  
  492.        MROW=ULR%+1
  493.        GOSUB TAGLIST.DISP
  494.  
  495.        MROW=LRR+1
  496.        GOSUB TAGLIST.DISP
  497.  
  498.        RETURN
  499.  
  500. '
  501. 'are we on the first screen of items
  502. '
  503. '      IF BEGVAL > 1 THEN
  504. '           MROW=ULR+1
  505. '           DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
  506. '           GOSUB TAGLIST.DISP
  507. '      ENDIF
  508.  
  509. '
  510. 'are we neither at the top nor bottom of the list of items being displayed
  511. '
  512. '      IF ENDVAL < MAXITEMS% THEN
  513. '           MROW=LRR+1
  514. '           DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
  515. '           GOSUB TAGLIST.DISP
  516. '      ENDIF
  517. '
  518. '      IF SELECT.% = 1 THEN
  519. '           MROW=ULR+1
  520. '           DAT$=CHR$(205)+CHR$(205)+" "+CHR$(31)+" "+CHR$(205)+CHR$(205)
  521. '           GOSUB TAGLIST.DISP
  522. '      ENDIF
  523. '
  524. '      IF SELECT.% = MAXITEMS% THEN
  525. '           MROW=LRR+1
  526. '           DAT$=CHR$(205)+CHR$(205)+" "+CHR$(30)+" "+CHR$(205)+CHR$(205)
  527. '           GOSUB TAGLIST.DISP
  528. '      ENDIF
  529. '
  530.  
  531. '
  532. TAGLIST.DISP:
  533.        ATTR=(BACK% AND 7)*16+FORE%
  534.        CALL FASTPRT(DAT$,MROW,MCOL,ATTR)
  535.        RETURN
  536.  
  537. '
  538. '
  539. ' Scan the list of items item looking for an item whose fitst character
  540. 'matches the keyboard character the user just typed.
  541. '
  542. TAGLIST.FIND.OPTION:
  543.        SAVE.SELECT=SELECT.%                 'save the current item highlighted
  544.        TEMP.SELECT=SELECT.%
  545.        FIRST.CHAR$=KP$                      'this is the character to look for
  546.        COUNT=0                              'how many items have looked at
  547. TAGLIST.FIND.LOOP:
  548.        TEMP.SELECT=TEMP.SELECT+1            'look at the item after the current one
  549.        IF TEMP.SELECT>MAXITEMS% THEN        'are we at the end of the list
  550.            TEMP.SELECT=1                    'Yes start back at the first item in the list
  551.        ENDIF
  552.  
  553.        COUNT=COUNT+1                        'we have looked at this many items so far
  554.        IF COUNT>MAXITEMS% THEN              'have we looked at all the items in the list
  555.            RETURN                           'YES
  556.        ENDIF
  557.  
  558.        MID$(TEMP.ITEM$,1)=ITEM$((TEMP.SELECT-SELECT.BASE)+ITEM.MIN)
  559.        LEN.TEMP.ITEM=LEN(ITEM$((TEMP.SELECT-SELECT.BASE)+ITEM.MIN))
  560.  
  561. '
  562. 'scan over leading spaces for this item, up to first character
  563. '
  564.        FOR I=1 TO LEN.TEMP.ITEM
  565.        IF MID$(TEMP.ITEM$,I,1)<>" " THEN
  566.            IF MID$(TEMP.ITEM$,I,1)=FIRST.CHAR$ THEN
  567.                GOTO TAGLIST.FOUND.IT        'this one was a match
  568.            ELSE
  569.              GOTO TAGLIST.FIND.LOOP         'not this one, keep looking
  570.            ENDIF
  571.        ENDIF
  572.  
  573.        NEXT
  574.  
  575.        GOTO TAGLIST.FIND.LOOP               'not this one, keep looking
  576.  
  577. '
  578. TAGLIST.FOUND.IT:
  579.        SELECT.%=TEMP.SELECT                   'this is the item to select now
  580.  
  581.        OLD=SELECT.%
  582.        BEGVAL=SELECT.%                        'start the display window with this item
  583.        ENDVAL=(BEGVAL+SHOWITEMS%)-1           'and end with this item
  584.  
  585.        IF ENDVAL > MAXITEMS% THEN             'are there enought items to fill this window
  586.            ENDVAL=MAXITEMS%                   'NO, so display the last group of items
  587.            BEGVAL=(ENDVAL-SHOWITEMS%)+1       'and highlight the one found
  588.        ENDIF
  589.  
  590.        GOSUB TAGLIST.FILL                     'display the group of items and highlight one found
  591.        RETURN
  592.  
  593. '
  594. '
  595. ' Look for a keyboard key press or a mouse action and return a 'keystroke'
  596. '
  597. TAGLIST.GET.PRESS:
  598.        IF BUTTONS%=0 THEN                     'is a mouse supported?
  599.           GOTO TAGLIST.GET.INKEY              'no, just look at the keyboard
  600.        ENDIF
  601.  
  602.        CALL MMGETLOC(MOUSECOL,MOUSEROW)       'get the current mouse cursor scrren location
  603.  
  604.        MOUSEROW=(MOUSEROW\8)+1                'convert row to 80x25 co-ordinates
  605.        MOUSECOL=(MOUSECOL\8)+1                'convert columnto 80x25 co-ordinates
  606.  
  607. '
  608. ' Check if the mouse is still in the window box
  609. '
  610. TAGLIST.CHECK.IF.INBOX:
  611.  
  612. '
  613. ' Is the mouse outside the window frame
  614. '
  615.        IF (MOUSEROW<MENU.TOP.ROW) OR (MOUSEROW>MENU.BOTTOM.ROW) THEN
  616.           GOTO TAGLIST.OUTSIDE.BOX
  617.        ENDIF
  618.  
  619. '
  620. ' Is the mouse in the box or on the window frame
  621. '
  622.        IF (MOUSECOL>=MENU.TOP.LEFT.COL) AND (MOUSECOL<=MENU.BOTTOM.RIGHT.COL) THEN
  623.           GOTO TAGLIST.FOUNDIT
  624.        ENDIF
  625.  
  626. '
  627. ' Mouse cursor is outside the window, did user click any buttons
  628. '
  629. TAGLIST.OUTSIDE.BOX:
  630.        CALL MMCLICK(LFT%,RGT%)                'see if left or right button clicked?
  631.        CLICK=LFT%+RGT%
  632.        IF CLICK=0 THEN                        'any button clicked?
  633.            GOTO TAGLIST.OUTSIDE.BOX.CONT      'NO
  634.        ENDIF
  635.  
  636. '
  637. 'If any button clicked outside window then simualte an ESC key press
  638. '
  639.        IF (MOUSECOL<MENU.TOP.LEFT.COL-1) OR (MOUSECOL>MENU.BOTTOM.RIGHT.COL+1) THEN
  640.             KP$=CHR$(27)                      'simulate ESC key press
  641.            RETURN
  642.        ENDIF
  643.  
  644. '
  645. ' Mouse was clicked on the top or bottom window frame, get the character under
  646. 'the mouse cursor (on the screen)
  647. '
  648.        SCREEN.CHR=SCREEN(MOUSEROW,MOUSECOL)
  649.  
  650.        KP$=CHR$(0)+CHR$(73)                   'assume 'page up' to be simulated
  651.  
  652.        IF MOUSEROW=MENU.TOP.ROW-1 THEN        'mouse on upper window frame?
  653.            IF SHOWITEMS%<>MAXITEMS% THEN      'are we doing POPMENU
  654.              IF SCREEN.CHR=31 THEN            'NO, user click on 'down' arrow
  655.                    KP$=CHR$(0)+CHR$(81)       'YES, simulate 'page down' keystroke
  656.                  RETURN
  657.              ELSEIF SCREEN.CHR=30 THEN        'was mouse cursor on 'up' character
  658.                  RETURN
  659.              ELSE
  660.                  RETURN
  661.              ENDIF
  662.            ENDIF
  663.        ENDIF
  664.  
  665.        KP$=CHR$(0)+CHR$(81)                   'assume 'page down' to be simulated
  666.  
  667.        IF MOUSEROW=MENU.BOTTOM.ROW+1 THEN     'mouse on bottom window frame?
  668.            IF SHOWITEMS%<>MAXITEMS% THEN      'are we doing POPMENU
  669.              IF SCREEN.CHR=30 THEN            'NO, user click on 'up' arrow
  670.                    KP$=CHR$(0)+CHR$(73)       'YES, simulate 'page up' keystroke
  671.                  RETURN
  672.              ELSEIF SCREEN.CHR=31 THEN        'was mouse on 'down' character
  673.                  RETURN
  674.              ELSE
  675.                  RETURN
  676.              ENDIF
  677.            ENDIF
  678.        ENDIF
  679.  
  680.        KP$=CHR$(27)                           'Simualate an ESC keypress
  681.        RETURN
  682.  
  683. TAGLIST.OUTSIDE.BOX.CONT:
  684.        GOSUB TAGLIST.MMCURSORON               'turn the mouse cursor on
  685.        GOTO TAGLIST.GET.INKEY                 'see if a keyboard key pressed
  686.  
  687. '
  688. TAGLIST.FOUNDIT:
  689.        SELECT.%=BEGVAL+(MOUSEROW-MENU.TOP.ROW) 'this is the one we want to highlight now
  690.  
  691.        IF SELECT.%<>OLD THEN                   'are we on the same one as is currently highlighted
  692.             GOSUB TAGLIST.FILL                 'NO, so highlight the newone just selected with the mouse
  693.             OLD=SELECT.%
  694.             GOSUB TAGLIST.MMCURSOROFF          'turn off the mouse cursor
  695.             CALL MMCLICK(LFT%,RGT%)            'clear any mouse clicks
  696.          GOTO TAGLIST.GET.INKEY
  697.        ENDIF
  698.  
  699.        GOSUB TAGLIST.MMCURSOROFF               'turn off the mouse cursor
  700.  
  701.        CALL MMCLICK(LFT%,RGT%)                 'see if mouse clicked on the current highlighted item
  702.  
  703.        CLICK=LFT%+RGT%                         'was right or left button clicked?
  704.  
  705.        IF CLICK=0 THEN                         'a button clicked?
  706.           GOTO TAGLIST.GET.INKEY               'NO
  707.        ENDIF
  708.  
  709.        IF RGT% THEN                            'was right button pressed?
  710.             KP$=CHR$(13)                       'Yes simulate a ENTER keypress
  711.          RETURN
  712.        ENDIF
  713.  
  714.        IF LFT%<1 THEN                          'was left button pressed
  715.           GOTO TAGLIST.GET.INKEY               'NO
  716.        ENDIF
  717.  
  718.        KP$=CHR$(0)+CHR$(82)                    'assume INS keypress to be simulated
  719.  
  720.        IF TAGITEMS%(SELECT.SUB)=1 THEN         'if item already tagged
  721.            KP$=CHR$(0)+CHR$(83)                'simulate a DEL keypress
  722.        ENDIF
  723.  
  724.        RETURN
  725.  
  726. TAGLIST.GET.INKEY:
  727.        KP$=INKEY$                             'get a keyboard keypress character, if one avail.
  728.  
  729.        IF LEN(KP$)=0 THEN                     'keep looking for a mouse or keyboard action
  730.           GOTO TAGLIST.GET.PRESS
  731.        ENDIF
  732.  
  733.        RETURN
  734.  
  735. '
  736. '
  737. ' The Window upper left frame co-ordinates were defined
  738. '
  739. TAGLIST.GETORD:
  740.        QUADRANT$=LTRIM$(QUADRANT$)            'strip off any leading and trailing spaces
  741.        QUADRANT$=RTRIM$(QUADRANT$)
  742.  
  743.        COLON.LOC=INSTR(QUADRANT$,":")         'find where the row/column separator char is loacted
  744.  
  745.        IF COLON.LOC=1 THEN                    'was a row defined
  746.            QUADRANT$="01"+QUADRANT$           'NO, so default to row 02
  747.            COLON.LOC=3
  748.        ENDIF
  749.  
  750.        ULR%=VAL(LEFT$(QUADRANT$,COLON.LOC-1)) 'convert row to a interger. to work with
  751.  
  752.        IF (ULR%<1) OR (ULR%>24) THEN          'is row in valid range of screen co-ordinates
  753.           ULR%=2                              'no, so default to row 02
  754.        ENDIF
  755.  
  756.        IF COLON.LOC=LEN(QUADRANT$) THEN       'was a column co-ordinate defined
  757.           QUADRANT$=QUADRANT$+"00"            'NO, so default to 00
  758.        ENDIF
  759.  
  760.        ULC%=VAL(MID$(QUADRANT$,COLON.LOC+1))  'convert column to interger, to work with
  761.        IF (ULC%<1) OR (ULC%>80) THEN          'is the column in a valid range
  762.            GOSUB TAGLIST.CENTER.ON.THE.LINE   'NO, so center the window on the row
  763.        ENDIF
  764.  
  765.        QUADRANT.ROW$=STR$(ULR%)               'return the string of the row and column we are working with
  766.        QUADRANT$="0"+RIGHT$(QUADRANT.ROW$,LEN(QUADRANT.ROW$)-1)+":"
  767.        QUADRANT.COL$=STR$(ULC%)
  768.        QUADRANT$=QUADRANT$+"0"+RIGHT$(QUADRANT.COL$,LEN(QUADRANT.COL$)-1)
  769.  
  770.        LRR=ULR+SHOWITEMS%+1                   'calculate the windows lower right row and column co-ord.
  771.        LRC=ULC+WINDLEN-1
  772.        RETURN
  773.  
  774. TAGLIST.CENTER.ON.THE.LINE:
  775.        TEMP.ULC=40-(WINDLEN/2)                 'calculate the center point on the row
  776.        IF (ULC<2) THEN                         'would window be outside screen?
  777.           TEMP.ULC=2                           'put it back in scrren and allow for frame (but not shadow)
  778.        ENDIF
  779.  
  780.        ULC=TEMP.ULC                            'this is the upper left column needed to center this window
  781.  
  782.        RETURN
  783.  
  784. '
  785. '
  786. ' Center the window frame header, within the window.
  787. '
  788. TAGLIST.PUTHDR:
  789.        PAD=(WINDLEN/2)-(LEN(HEADER$)/2)-.5
  790.        MID$(TEMPHDR$,PAD+1,LEN(HEADER$))=HEADER$
  791.        HEADER$=TEMPHDR$
  792.        RETURN
  793.  
  794. '
  795. TAGLIST.MMCURSORON:
  796.        IF BUTTONS%=0 THEN                     'is a mouse supported?
  797.            RETURN                             'NO
  798.        ENDIF
  799.  
  800.        IF MOUSE.CURSOR=0 THEN                 'is the mouse off at present?
  801.           CALL MMCURSORON                     'YES, turn it on
  802.           MOUSE.CURSOR=-1
  803.        ENDIF
  804.  
  805.        RETURN
  806.  
  807. TAGLIST.MMCURSOROFF:
  808.        IF BUTTONS%=0 THEN                     'is a mouse supported?
  809.            RETURN                             'NO
  810.        ENDIF
  811.  
  812.        IF MOUSE.CURSOR=-1 THEN                'is the mouse on at present?
  813.           CALL MMCURSOROFF                    'YES, turn it off
  814.           MOUSE.CURSOR=0
  815.        ENDIF
  816.  
  817.        RETURN
  818.  
  819. '
  820. TAGLIST.SOUNDOFF:
  821.        SOUND 1000,1
  822.        SOUND 1500,2
  823.        SOUND 500,1
  824.        RETURN
  825.  
  826. '
  827. TAGLIST.DONE:
  828.        GOSUB TAGLIST.MMCURSOROFF              'turn the mouse off as we leave
  829.  
  830.        TEMP.ITEM$=""                          'free string space
  831.        HEADER$=""
  832.        TEMPHDR$=""
  833.        DAT$=""
  834.  
  835.        EXIT SUB                               'return to caller
  836. END SUB
  837.