home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR36 / C7101.ZIP / BROWSE.CLA < prev    next >
Text File  |  1994-02-02  |  42KB  |  619 lines

  1.                  PROGRAM
  2. OMIT('┘')
  3. ┌───────────────────────────────────────────────────────────┬────────────────┐
  4. │                                                           │Version:3007.101│
  5. ├───────────────────────────────────────────────────────────┴────────────────┤
  6. │        BROWSE.CLA - The Browse Support Module                              │
  7. │                                                                            │
  8. │        The Browse Support Module manages the process of scrolling records  │
  9. │        through a list box.  Browse support is conducted in a session that  │
  10. │        is initiated by the BeginBrowse procedure and terminated by the     │
  11. │        EndBrowse procedure.  Multiple browse sessions may be conducted at  │
  12. │        the same time (e.g. a browse procedure calls a form which calls a   │
  13. │        lookup procedure).  The current status of a browse session is       │
  14. │        stored in a Session queue.  The browse process uses a position      │
  15. │        queue which contains a POSITION() string used to access displayed   │
  16. │        records.                                                            │
  17. │                                                                            │
  18. │        BeginBrowse(List,Locator,Immediate,Increment,Nomemo)                │
  19. │                                                                            │
  20. │            Initiate a browse session and append a new element to the       │
  21. │            Session queue.  Fixed (non-scrolling) queue elements should be  │
  22. │            the only elements in the list queue when a session begins.      │
  23. │                                                                            │
  24. │            "List" is the field number of a list box that displays a queue  │
  25. │            of formatted records.                                           │
  26. │                                                                            │
  27. │            "Locator" is an optional parameter that contains the field      │
  28. │            number of a locator field.  Typing any displayable character    │
  29. │            activates the locator field.  The USE variable of the locator   │
  30. │            field must be a key component, so completing the locator field  │
  31. │            scrolls the list box to the first matching record.              │
  32. │                                                                            │
  33. │            "Immediate" is an optional parameter that contains a 1 if the   │
  34. │            selected record is to be accessed each time the selector bar    │
  35. │            moves over a new record.                                        │
  36. │                                                                            │
  37. │            "Increment" is an optional parameter that contains a 1, 2, 3,   │
  38. │            or 4 to request an incremental locator field that automatically │
  39. │            locates a matching record after a pause in typing.  Increment   │
  40. │            values of 2, 3, and 4 request upper case, lower case, and       │
  41. │            capitalized locator fields.  An increment value of 1 uses the   │
  42. │            case entered by the operator.                                   │
  43. │                                                                            │
  44. │            "Nomemo" is an optional parameter that contains a 1 or 2 to     │
  45. │            disarm memo fields.  A value of 1 means that memos are not      │
  46. │            displayed in the list box.  A value of 2 means, in addition,    │
  47. │            that memos are not used as hot fields.  Memos are always        │
  48. │            retrieved for "Process Field" actions.                          │
  49. │                                                                            │
  50. │        BrowseAction(File,Key,Queue)                                        │
  51. │                                                                            │
  52. │            Manages the behavior of the list box, locator field, and hot    │
  53. │            fields.                                                         │
  54. │                                                                            │
  55. │            "File" is the FILE to be scrolled.                              │
  56. │                                                                            │
  57. │            "Key" is KEY to be used to access the file.                     │
  58. │                                                                            │
  59. │            "Queue" is the display queue, declared by the caller and used   │
  60. │            as the parameter of the FROM attribute of the list box.         │
  61. │                                                                            │
  62. │            BrowseAction returns a code requesting one of the following     │
  63. │            actions: the following actions:                                 │
  64. │                                                                            │
  65. │              Set the first record and set the last record of a limited     │
  66. │              range of consecutive records.                                 │
  67. │                                                                            │
  68. │              Reject a record by issueing GET(File,0) to dereference the    │
  69. │              record or indicate that a record is out of range by issueing  │
  70. │              NEXT(File) or PREVIOUS(File) to move the record position.     │
  71. │                                                                            │
  72. │              Format a display queue element for the current record.  The   │
  73. │              queue element will be placed in the display queue by the      │
  74. │              browse manager.                                               │
  75. │                                                                            │
  76. │              Process the record under the selector bar                     │
  77. │                                                                            │
  78. │              Process a field or key that the browse manager does not       │
  79. │              recognize.  The selected record has been accessed from the    │
  80. │              file and display queue.                                       │
  81. │                                                                            │
  82. │              Take action if there are no records to display.               │
  83. │                                                                            │
  84. │              Clear the key fields subordinate to the locator field.        │
  85. │                                                                            │
  86. │        EndBrowse                                                           │
  87. │                                                                            │
  88. │            Terminate the browse session.  Free position elements for this  │
  89. │            session from the Position queue.  Free the last element from    │
  90. │            the Session queue.                                              │
  91. │                                                                            │
  92. └────────────────────────────────────────────────────────────────────────────┘
  93.                  INCLUDE('KEYCODES.EQU')
  94.                  MAP
  95.                    BeginBrowse(SHORT,<SHORT>,<BYTE>,<BYTE>,<BYTE>)
  96.                    BrowseAction(FILE,KEY,QUEUE),BYTE
  97.                    EndBrowse
  98.                  END
  99.  
  100. Session          QUEUE                           !Browse session queue
  101. Action             BYTE                          ! Caller action
  102. Process            BYTE                          ! Internal process
  103. List               SHORT                         ! List field number
  104. Locator            SHORT                         ! Locator field number
  105. Immediate          BYTE                          ! Immediate processing flag
  106. Increment          BYTE                          ! Incremental locator flag
  107. Nomemo             BYTE                          ! No memo retrieval flag
  108. Location           STRING(40)                    ! Locator field contents
  109. Length             BYTE                          ! Locator contents length
  110. Count              BYTE                          ! List item count
  111. Fixed              BYTE                          ! Fixed list item count
  112. Item               BYTE                          ! Current item (1 to Count)
  113. Choice             BYTE                          ! Selector bar position
  114. LastChoice         BYTE                          ! Last Selector position
  115. Page               STRING(1)                     ! Current page (F,L,N,blank)
  116. FirstPage          BYTE                          ! First page request flag
  117. Base               SHORT                         ! Base for position queue
  118. Selected           STRING(256)                   ! Selected record position
  119.                  END
  120.  
  121. Position         QUEUE                           !Record position queue
  122.                    STRING(256)                   ! Record Position
  123.                  END
  124.                                                  !Caller actions
  125. NoAction         EQUATE(0)                       ! No caller action
  126. FormatQueue      EQUATE(1)                       ! Format the display queue
  127. ProcessField     EQUATE(2)                       ! Process another field
  128. NoRecords        EQUATE(3)                       ! No records to display
  129. FilterRecord     EQUATE(4)                       ! Filter a record
  130. ResetFirst       EQUATE(5)                       ! Set to first of a range
  131. ResetLast        EQUATE(6)                       ! Set to last of a range
  132. ProcessSelected  EQUATE(7)                       ! Process selected record
  133. ClearRestOfKey   EQUATE(8)                       ! Clear low fields of key
  134.  
  135.                                                  !Internal processes
  136. InitSession      EQUATE(1)                       ! Initialize browse session
  137. ProcessForward   EQUATE(2)                       ! Process records forward
  138. ProcessBackward  EQUATE(3)                       ! Process records backward
  139. ProcessSingle    EQUATE(4)                       ! Process a single record
  140. AcceptInput      EQUATE(5)                       ! Accept keyboard input
  141.  
  142. LoChar           EQUATE(32)                      !Lowest displayable char
  143. HiChar           EQUATE(127)                     !Highest displayable char
  144.  
  145.                  CODE                            !Dummy program
  146.  
  147. BeginBrowse      PROCEDURE(InList,InLocator,InImmediate,InIncrement,InNomemo)
  148.  
  149.   CODE
  150.   IF RECORDS(Session) THEN PUT(Session).         !Save any current session
  151.   CLEAR(Session)                                 !Clear the session record
  152.   Action = NoAction                              !Set no caller action
  153.   Process = InitSession                          !Initialize a browse session
  154.   List = InList                                  !Set list field number
  155.   Locator = InLocator                            !Set locator field number
  156.   Immediate = InImmediate                        !Set immediate process flag
  157.   IF Locator THEN Increment = InIncrement.       !If there is a locator field
  158.   Nomemo = InNomemo                              !Set no memo flag
  159.   Count = ROWS(List)                             !Set item count
  160.   Choice = 1                                     !Set top choice
  161.   LastChoice = 1                                 !Set top last choice
  162.   Base = RECORDS(Position)                       !Set base position
  163.   ADD(Session,RECORDS(Session)+1)                !Add the session record
  164.   RETURN                                         !Return to caller
  165.  
  166. BrowseAction     FUNCTION(File,Key,Queue)
  167.  
  168. Delay            EQUATE(50)                      !Time delay (1/2 second)
  169. SpaceKey         EQUATE(32)                      !Space bar keycode
  170. TimeOut          LONG                            !Deadline time (.01 seconds)
  171. LocatorContents  STRING(255)                     !Locator field contents
  172.  
  173.   CODE
  174.   CASE Action                                    !Process caller's action
  175.   OF FilterRecord                                !Caller filtered the record
  176.     CASE POSITION(Key)                           ! Check callers action
  177.     OF ''                                        ! The record is rejected
  178.       IF Process = ProcessSingle                 !  And previously accepted
  179.         DELETE(Queue)                            !   Delete the queue element
  180.         GET(Position,Base+Choice-Fixed)          !   Get the position element
  181.         DELETE(Position)                         !   And delete it
  182.         Process = ProcessForward                 !   Display a new last
  183.         Item = RECORDS(Queue) + 1                !    record forward
  184.         GET(Position,RECORDS(Position))          !   Get last display record
  185.         RESET(Key,Position)                      !   Reset to last display
  186.         NEXT(File)                               !   Retrieve last record
  187.       END                                        !  End IF
  188.     OF Position                                  ! The record is accepted
  189.       Action = FormatQueue                       !  Ask caller to format
  190.       RETURN(Action)                             !  Return to caller
  191.     ELSE                                         ! The record is out of range
  192.       DISPLAY(List)                              !  Display the page
  193.       SELECT(List,Choice)                        !  Select the list box
  194.       Selected = ''                              !  Clear selected position
  195.       Process = AcceptInput                      !  Get keyboard input
  196.     END                                          ! End CASE
  197.  
  198.   OF FormatQueue                                 !Caller formatted the queue
  199.     CASE Process                                 ! Jump to current process
  200.     OF ProcessForward                            ! On forward processing
  201.       ADD(Queue,RECORDS(Queue)+1)                !  Add new last element
  202.       ADD(Position,RECORDS(Position)+1)          !  Add new last position
  203.       IF RECORDS(Queue) > Count                  !  If the page overflows
  204.         GET(Queue,Fixed+1)                       !   Get the first element
  205.         DELETE(Queue)                            !   And delete it
  206.         GET(Position,Base+1)                     !   Get the first position
  207.         DELETE(Position)                         !   And delete it
  208.       END                                        !  End IF
  209.       Item += 1                                  !  Increment current item
  210.     OF ProcessBackward                           ! On backward processing
  211.       ADD(Queue,Fixed+1)                         !  Add new first element
  212.       ADD(Position,Base+1)                       !  Add new first position
  213.       IF RECORDS(Queue) > Count                  !  If the page overflows
  214.         GET(Queue,RECORDS(Queue))                !   Get the last element
  215.         DELETE(Queue)                            !   And delete it
  216.         GET(Position,RECORDS(Position))          !   GET the last position
  217.         DELETE(Position)                         !   And delete it
  218.       END                                        !  End IF
  219.       Item -= 1                                  !  Decrement current item
  220.     OF ProcessSingle                             ! On a single record
  221.       PUT(Queue)                                 !  Replace the element
  222.       DISPLAY(List)                              !  Display the page
  223.       SELECT(List,Choice)                        !  Select the list box
  224.       Process = AcceptInput                      !  Get keyboard input
  225.       Selected = ''                              !  Clear selected position
  226.     END                                          ! End CASE
  227.  
  228.   OF ProcessSelected                             !Caller processed a record
  229.     Selected = POSITION(Key)                     ! Set selected position
  230.  
  231.   OF ProcessField                                ! Caller processed a field
  232.     IF Process = InitSession                     ! If we got here from Init code
  233.       Process = AcceptInput                      !  Skip internal field handling
  234.       Action = NoAction                          !  Clear ACTION
  235.       RETURN(Action)                             !  And go another time around
  236.     END                                          ! END (If we got here...)
  237.     IF FIELD() <> Locator                        ! For non-locator field
  238.       IF Increment                               !  If incremental locator
  239.         DO ClearLocator                          !   Clear locator
  240.       END                                        !  End IF
  241.       IF INRANGE(FIELD(),1,List-1)               !  From a prior field
  242.         FirstPage = 1                            !   Request the first page
  243.       END                                        !  End IF
  244.     END                                          ! End IF
  245.     IF SELECTED() = List                         ! If list field is selected
  246.       IF FirstPage                               !  If first page is requested
  247.         DO FirstPage                             !   Display the first page
  248.         Action = ResetFirst                      !   Ask caller to first
  249.         RETURN(Action)                           !    record in range
  250.       ELSIF FIELD() <> Locator                   !  From any but the locator
  251.         CASE POSITION(Key)                       !   Check the record
  252.         OF ''                                    !   If record was dereferenced
  253.           DO GetChoice                           !    Get selected record
  254.           IF POSITION(Key) = Position            !    If record is still there
  255.             Process = ProcessSingle              !     Display one record
  256.             Action = FilterRecord                !     Ask caller to filter
  257.             RETURN(Action)                       !     Return to caller
  258.           ELSE                                   !    If record was deleted
  259.             DELETE(Queue)                        !     Delete the element
  260.             DELETE(Position)                     !     Delete its position
  261.             IF RECORDS(Queue) = Fixed            !     If queue is now empty
  262.               DO LastPage                        !      Display the last page
  263.               Action = ResetLast                 !      Ask caller to reset to
  264.               RETURN(Action)                     !       last record in range
  265.             ELSE                                 !     Otherwise
  266.               Process = ProcessForward           !      Display a new
  267.               Item = RECORDS(Queue) + 1          !       last record
  268.               GET(Position,RECORDS(Position))    !      Reset to the bottom
  269.               RESET(Key,Position)                !       record displayed
  270.               NEXT(File)                         !      Read the record
  271.             END                                  !     End IF
  272.           END                                    !    End IF
  273.         OF Position                              !   If record didn't move
  274.           GET(Queue,Choice)                      !    Get display element
  275.           Action = FilterRecord                  !    Ask caller to
  276.           Process = ProcessSingle                !     filter one record
  277.           RETURN(Action)                         !    Return to caller
  278.         ELSE                                     !   If record moved
  279.           DO NewPage                             !    Display the new page
  280.         END                                      !   End CASE
  281.       END                                        !  End IF
  282.     ELSE                                         ! Else another field selected
  283.       IF FIELD() <> SELECTED()                   !  If selecting a new field
  284.         Process = AcceptInput                    !    Accept keyboard input
  285.       END                                        !  End IF
  286.     END                                          ! End IF
  287.  
  288.   OF NoRecords                                   !Caller added a record
  289.     IF SELECTED() = List                         ! And selected the list field
  290.       DO FirstPage                               !  Display the first page
  291.       Action = ResetFirst                        !  Ask caller to reset to
  292.       RETURN(Action)                             !   first record in range
  293.     END                                          ! End IF
  294.  
  295.   OF ClearRestOfKey                              !Caller cleared subfields
  296.     SELECT(Locator)                              !  Select the locator field
  297.     Process = AcceptInput                        !  Accept keyboard input
  298.   END                                            !End CASE
  299.  
  300.   LOOP                                           !Main processing loop
  301.     CASE Process                                 !Jump to current process
  302.     OF InitSession                               !Start browse session
  303.       Fixed = RECORDS(Queue)                     ! Set fixed list item count
  304.       Process = AcceptInput                      ! Accept keyboard input
  305.       IF List <> 1                               ! If the List is not first
  306.         Action = ProcessField                    !   Process any FIELD code
  307.         RETURN(Action)                           !   Do It!
  308.       END                                        ! END (If the List...)
  309.     OF ProcessForward                            !Process records forward
  310.       IF Item <= Count                           ! If page is not full
  311.         IF Nomemo THEN NOMEMO(File).             !  Disarm unneeded memos
  312.         NEXT(File)                               !  Read the next record
  313.         IF ~ERRORCODE()                          !  If a record was found
  314.           Position = POSITION(Key)               !   Save its position
  315.           Action = FilterRecord                  !   Ask caller to filter
  316.           RETURN(Action)                         !   Return to caller
  317.         ELSE                                     !  If no record was found
  318.           IF INSTRING(Page,'FN')                 !   For first or new page
  319.             Process = ProcessBackward            !    Display prior records
  320.             Item = Count - Item + Fixed + 1      !     from the top record
  321.             IF RECORDS(Position) > Base          !    For a partial screen
  322.               GET(Position,Base+1)               !     Get top position
  323.               RESET(Key,Position)                !     Reset to top record
  324.               PREVIOUS(File)                     !     Point to prior page
  325.               CYCLE                              !     Process backwards
  326.             ELSE                                 !    For a blank screen
  327.               SET(Key)                           !     Set to end of file
  328.               Action = ResetLast                 !     Ask caller to reset
  329.               RETURN(Action)                     !     Return to caller
  330.             END                                  !    End IF
  331.           END                                    !   End IF
  332.         END                                      !  End IF
  333.       END                                        ! End IF
  334.       DISPLAY(List)                              ! Display the page
  335.       SELECT(List,Choice)                        ! Select the list box
  336.       Selected = ''                              ! Clear selected position
  337.       Process = AcceptInput                      ! Get keyboard input
  338.  
  339.     OF ProcessBackward                           !Process records backward
  340.       IF Item >= Fixed + 1                       ! If page is not full
  341.         IF Nomemo THEN NOMEMO(File).             !  Disarm unneeded memos
  342.         PREVIOUS(File)                           !  Read the prior record
  343.         IF ~ERRORCODE()                          !  If a record was found
  344.           IF INSTRING(Page,'FN',1,1) THEN Choice += 1.! Increment selector bar
  345.           Position = POSITION(Key)               !   Save its position
  346.           Action = FilterRecord                  !   Ask caller to filter
  347.           RETURN(Action)                         !   Return to caller
  348.         END                                      !  End IF
  349.       END                                        ! If page is full
  350.       DISPLAY(List)                              !  Display the page
  351.       SELECT(List,Choice)                        !  Select the list box
  352.       Selected = ''                              !  Clear selected position
  353.       Process = AcceptInput                      !  Get keyboard input
  354.  
  355.     OF AcceptInput                               !Get keyboard input
  356.       IF SELECTED() = List                       ! If the list box is selected
  357.         IF RECORDS(Queue) = Fixed                !  If there are no records
  358.           CASE Page                              !   Jump to current page
  359.           OF 'F'                                 !   On the first page
  360.             GET(File,0)                          !    Clear the current record
  361.             Action = NoRecords                   !    Ask caller for records
  362.           OF 'N'                                 !   On a new page
  363.             DO LastPage                          !    Display the last page
  364.             Action = ResetLast                   !    Ask for last record
  365.           ELSE                                   !   On any other page
  366.             DO FirstPage                         !    Display the first page
  367.             Action = ResetFirst                  !    Ask for first record
  368.           END                                    !   End CASE
  369.           RETURN(Action)                         !   Return to caller
  370.         END                                      !  End IF
  371.  
  372.         IF Immediate                             ! For immediate processing
  373.           GET(Position,Base+CHOICE(List)-Fixed)  !  Get selected position
  374.           IF Selected <> Position                !  If selector moved
  375.             GET(Position,Base+Choice-Fixed)      !   Get selected position
  376.             RESET(Key,Position)                  !   Reset to that record
  377.             IF Nomemo = 2 THEN NOMEMO(File).     !   Disarm unneeded memos
  378.             NEXT(File)                           !   Read the record
  379.             IF Position = POSITION(Key)          !   If record is there
  380.               Action = ProcessSelected           !    Ask to process record
  381.               RETURN(Action)                     !    Return to caller
  382.             ELSE                                 !   Else
  383.               DO NewPage                         !    Rebuild the Queue
  384.               Action = ProcessField              !    Ask to process record
  385.               RETURN(Action)                     !    Return to caller
  386.             END                                  !   End IF
  387.           END                                    !  End IF
  388.         END                                      ! End IF
  389.         IF Locator                               ! If there is a locator field
  390.           ERASE(Locator)                         !  Erase locator contents
  391.           IF Increment                           !  For incremental locator
  392.             DO ShowLocator                       !   Show locator field
  393.           END                                    !  End IF
  394.         END                                      ! End IF
  395.         LastChoice = CHOICE(List)                ! Save selector position
  396.       END                                        !End IF
  397.       ACCEPT                                     !Enable the keyboard
  398.       CASE FIELD()                               !Jump to field edit routine
  399.  
  400.       OF Locator                                 !Process the locator field
  401.         IF CONTENTS(Locator)                     ! If locator is requested
  402.           IF Increment                           !  If incremental locator
  403.             Location = CONTENTS(Locator)         !   Save location
  404.             Length = LEN(CLIP(Location))         !   Save location length
  405.           END                                    !  End IF
  406.           SELECT(List)                           !  Select the list box
  407.           DO NewPage                             !  Display a new page
  408.           Action = ProcessField                  !  Ask caller to process
  409.           RETURN(Action)                         !  Return to caller
  410.         ELSE                                     ! ELSE (If No Locator)
  411.           Action = ProcessField                  !  Ask caller to process
  412.           RETURN(Action)                         !  Return to caller
  413.         END                                      ! End IF
  414.  
  415.       OF List                                    !Process the list field
  416.         Choice = CHOICE(List)                    ! Save selector bar position
  417.         IF SELECTED() <> List                    ! Process any new fields
  418.           Action = ProcessField                  !  Ask caller to process
  419.           RETURN(Action)                         !  Return to caller
  420.         END                                      ! END (Process...)
  421.         CASE KEYCODE()                           ! Jump to key edit routine
  422.  
  423.         OF LoChar TO HiChar                      ! For any locator character
  424.         OROF BSKey OROF SpaceKey                 ! Or a backspace or space
  425.           IF Locator                             !  If there is a locator
  426.             IF Increment                         !   On incremental locator
  427.               DO GatherKeys                      !    Gather keystrokes
  428.               IF Location                        !    If not blank
  429.                 PRESS(SUB(Location,1,Length))    !     Press the string
  430.                 PRESS(DownKey)                   !     Complete the field
  431.                 SELECT(Locator)                  !     Select locator
  432.               END                                !    End IF
  433.             ELSE                                 !   On standard locator
  434.               PRESS(KEYCODE())                   !    Press in the keycode
  435.               SELECT(Locator)                    !    Select locator field
  436.             END                                  !   End IF
  437.             Action = ClearRestOfKey              !    Ask caller to clear
  438.             RETURN(Action)                       !     subordinate fields
  439.           END                                    !  End IF
  440.  
  441.         OF CtrlPgUp                              ! Process the Ctrl-PgUp key
  442.           DO FirstPage                           !  Display the first page
  443.           IF Increment                           !  If incremental locator
  444.             DO ClearLocator                      !   Clear locator field
  445.           END                                    !  End IF
  446.           Action = ResetFirst                    !  Ask caller to reset to
  447.           RETURN(Action)                         !   first record in range
  448.  
  449.         OF PgUpKey                               ! Process the PgUp key
  450.           IF LastChoice <> Fixed + 1             !  If not at the top
  451.             Choice = Fixed + 1                   !   Selector bar to top
  452.           ELSE                                   !  From the top
  453.             Page = ''                            !   Clear page flag
  454.             Process = ProcessBackward            !   Display a new page
  455.             Item = Count                         !    of records backward
  456.             GET(Position,Base+1)                 !   Reset to the top
  457.             RESET(Key,Position)                  !    record displayed
  458.             PREVIOUS(File)                       !   Point to prior record
  459.           END                                    !  End IF
  460.  
  461.         OF UpKey                                 ! Process the up arrow
  462.           IF LastChoice = Fixed + 1              !  From the top line
  463.             Page = ''                            !   Clear page flag
  464.             Process = ProcessBackward            !   Display a single
  465.             Item = Fixed + 1                     !    record backward
  466.             GET(Position,Base+1)                 !   Reset to the top
  467.             RESET(Key,Position)                  !    record displayed
  468.             PREVIOUS(File)                       !   Point to prior record
  469.           END                                    !  End IF
  470.  
  471.         OF DownKey                               ! Process the down arrow
  472.           IF LastChoice = Count                  !  From the bottom line
  473.             Page = ''                            !   Clear page flag
  474.             Process = ProcessForward             !   Display a single
  475.             Item = Count                         !    record forward
  476.             GET(Position,RECORDS(Position))      !   Reset to the bottom
  477.             RESET(Key,Position)                  !    record displayed
  478.             NEXT(File)                           !   Point to the next record
  479.           END                                    !  End IF
  480.  
  481.         OF PgDnKey                               ! Process the PgDn key
  482.           IF LastChoice <> Count                 !  If not at the bottom
  483.             Choice = Count                       !   Selector bar to bottom
  484.           ELSE                                   !  From the bottom
  485.             Page = ''                            !   Clear page flag
  486.             Process = ProcessForward             !   Display a new page
  487.             Item = 1 + Fixed                     !    of records forwards
  488.             GET(Position,RECORDS(Position))      !   Reset to the bottom
  489.             RESET(Key,Position)                  !    record displayed
  490.             NEXT(File)                           !   Point to the next record
  491.           END                                    !  End IF
  492.  
  493.         OF CtrlPgDn                              ! Process the Ctrl-PgDn Key
  494.           DO LastPage                            !  Display the last page
  495.           IF Increment                           !  If incremental locator
  496.             DO ClearLocator                      !   Clear locator field
  497.           END                                    !  End IF
  498.           Action = ResetLast                     !  Ask caller to reset to
  499.           RETURN(Action)                         !   last record in range
  500.  
  501.         OF   LeftKey                             ! For left arrow key,
  502.         OROF Rightkey                            ! Or right arrow key,
  503.         OROF Homekey                             ! Or Home key,
  504.         OROF Endkey                              ! Or End key,
  505.         OROF MouseLeft                           ! Or a mouse click
  506.                                                  !  Don't do anything
  507.         ELSE                                     ! For any other key
  508.           DO GetChoice                           !  Get selected record
  509.           Action = ProcessField                  !  Ask caller to process
  510.           RETURN(Action)                         !  Return to caller
  511.  
  512.         END                                      ! End CASE KEYCODE()
  513.         IF Increment                             ! If incremental locator
  514.           DO ClearLocator                        !  Clear locator field
  515.         END                                      ! End
  516.       ELSE                                       ! Process any other field
  517.         IF FIELD() >= List OR FIELD() < 0        !  If not list or setup fld
  518.           DO GetChoice                           !   Get selected record
  519.         ELSIF SELECTED() = List                  !  Else if reprocessing List
  520.           DO GetChoice                           !   Get selected record
  521.         END                                      !  End IF
  522.         Action = ProcessField                    !  Ask caller to process
  523.         RETURN(Action)                           !  Return to caller
  524.       END                                        ! End CASE FIELD()
  525.     END                                          !End CASE BrowseProcess
  526.   END                                            !End LOOP
  527.  
  528. GetChoice ROUTINE                                !Get selected record
  529.   GET(Queue,Choice)                              ! Get selected element
  530.   GET(Position,Base+Choice-Fixed)                ! Get selected position
  531.   RESET(Key,Position)                            ! Reset to that record
  532.   NEXT(File)                                     ! Read the record
  533.  
  534. FirstPage ROUTINE                                !Display first page
  535.   FirstPage = 0                                  ! Clear first page request
  536.   Page = 'F'                                     ! Set first page flag
  537.   DO DeletePage                                  ! Delete the old page
  538.   Choice = Fixed + 1                             ! Reset selector bar
  539.   Process = ProcessForward                       ! Display a new page
  540.   Item = Fixed + 1                               !  of records forward
  541.   SET(Key)                                       ! Set to the first record
  542.  
  543. LastPage ROUTINE                                 !Display last page
  544.   Page = 'L'                                     ! Set last page flag
  545.   DO DeletePage                                  ! Delete the old page
  546.   Choice = Count                                 ! Reset selector bar
  547.   Process = ProcessBackward                      ! Display a new page
  548.   Item = Count                                   !  of records backward
  549.   SET(Key)                                       ! Set to the last record
  550.  
  551. NewPage ROUTINE                                  !Display a new page
  552.   Page = 'N'                                     ! Set new page flag
  553.   DO DeletePage                                  ! Delete the old page
  554.   SET(Key,Key)                                   ! Set to the new record
  555.   Choice = Fixed + 1                             ! Selector bar to top
  556.   Process = ProcessForward                       ! Display a new page
  557.   Item = Fixed + 1                               !  of records forward
  558.  
  559. DeletePage ROUTINE                               !Delete the current page
  560.   LOOP WHILE RECORDS(Queue) > Fixed              ! Delete all queue
  561.     GET(Queue,RECORDS(Queue))                    !  elements after the
  562.     DELETE(Queue)                                !   fixed elements
  563.   END                                            ! End LOOP
  564.   LOOP WHILE RECORDS(Position) > Base            ! Delete all position
  565.     GET(Position,RECORDS(Position))              !  elements after the
  566.     DELETE(Position)                             !   base position
  567.   END                                            ! End LOOP
  568.  
  569. GatherKeys ROUTINE                               !Gather locator keystrokes
  570.   DO AppendKey                                   ! Append pending keystroke
  571.   TimeOut = CLOCK() + Delay                      ! Set the time delay
  572.   LOOP UNTIL CLOCK() > TimeOut                   ! Loop until time out
  573.     IF KEYBOARD()                                !  If there is a keystroke
  574.       ASK                                        !   Read the keystroke
  575.       DO AppendKey                               !   Append the keystroke
  576.       DO ShowLocator                             !   Show the user
  577.       TimeOut = CLOCK() + Delay                  !   Reset the time delay
  578.     END                                          !  End IF
  579.   END                                            ! End LOOP
  580.  
  581. AppendKey ROUTINE                                !Append keystroke to locator
  582.   CASE KEYCODE()                                 ! Process the keystroke
  583.   OF LoChar TO HiChar OROF SpaceKey              ! For a character
  584.     IF Length < COLS(Locator)                    !  If it will fit
  585.       Location = SUB(Location,1,Length) & CHR(KEYCODE()) ! Add it on
  586.       Length += 1                                !  Increment the length
  587.     END                                          !  End IF
  588.   OF BSKey                                       ! For a backspace
  589.     IF Length > 0 THEN Length -= 1.              !  Decrement the length
  590.     Location = SUB(Location,1,Length)            !  Shorten the string
  591.     EXECUTE Increment - 1                        !  For locator case
  592.       Location = UPPER(Location)                 !   Upper case location
  593.       Location = LOWER(Location)                 !   Lower case location
  594.       Location = UPPER(SUB(Location,1,1)) |      !   Capitalize location
  595.                & LOWER(SUB(Location,2,SIZE(Location)-1))
  596.     END                                          !  End EXECUTE
  597.   END                                            ! End CASE
  598.  
  599. ClearLocator ROUTINE                             !Clear locator field
  600.   Location = ''                                  ! Clear field string
  601.   Length = 0                                     ! Zero field length
  602.   DO ShowLocator                                 ! Show locator field
  603.  
  604. ShowLocator ROUTINE                              !Show locator field contents
  605.   SHOW(ROW(Locator),COL(Locator),SUB(Location,1,COLS(Locator)))
  606.  
  607. EndBrowse        PROCEDURE
  608.  
  609.   CODE
  610.   LOOP WHILE RECORDS(Position) > Base            !Delete all position
  611.     GET(Position,RECORDS(Position))              ! elements after the
  612.     DELETE(Position)                             !  base position
  613.   END                                            !End LOOP
  614.   DELETE(Session)                                !Delete the current session
  615.   IF RECORDS(Session)                            !For any prior session
  616.     GET(Session,RECORDS(Session))                ! Get the session element
  617.   END                                            !End IF
  618.   RETURN                                         !Return to caller
  619.