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

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