home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / formtbl.zip / FORMTBL.MDL < prev   
Text File  |  1989-07-06  |  29KB  |  765 lines

  1. *TABLE1*************************************************************************
  2. !     ╔═════════════════════════════════════════════════════════╗
  3. !     ║                                ║
  4. !     ║                                ║
  5. !     ║      06-15-89  John Crenshaw - EAS Technologies        ║
  6. !     ║            Louisville, KY.   502-473-1000        ║
  7. !     ║                                ║
  8. !     ║                                ║
  9. !     ║      06-23-89  Modified for 2008  JC            ║
  10. !     ║                                ║
  11. !     ║                                ║
  12. !     ║                                ║
  13. !     ║      Table 1   Calculates and passes current table row and ║
  14. !     ║            col to a form generated with the FORMTBL    ║
  15. !     ║            model. The variables TBLROW and TBLCOL(byte)║
  16. !     ║            must have been declared earlier.  I suggest ║
  17. !     ║            that you edit the global model and use it    ║
  18. !     ║            to declare the 2 variables.            ║
  19. !     ║                                ║
  20. !     ╚═════════════════════════════════════════════════════════╝
  21. @PROCNAME    PROCEDURE
  22.  
  23. SCREEN         SCREEN      PRE(SCR),@SCREENOPT
  24.               @PAINTS
  25.               @STRINGS
  26.               @VARIABLES
  27.               ENTRY,USE(?FIRST_FIELD)
  28.               @FIELDS
  29.               @PREPOINT
  30.               REPEAT(@COUNT),EVERY(@PROWS),INDEX(NDX)
  31.           @PLOC        POINT(@PROWS,@COLS),USE(?POINT),ESC(?-1)
  32.                 @SCROLLVARIABLES
  33.          .          .
  34.  
  35. TABLE         TABLE                 !TABLE OF RECORD POINTERS
  36. TBLPTR           LONG                 !  POINTER TO DATA RECORD
  37.          .
  38.  
  39. NDX         BYTE                 !REPEAT INDEX FOR POINT FIELD
  40. ROW         BYTE                 !ACTUAL ROW OF SCROLL AREA
  41. COL         BYTE                 !ACTUAL COLUMN OF SCROLL AREA
  42. MAX         LONG                 !LESSER OF COUNT AND RECORDS
  43. COUNT         BYTE(@COUNT)             !NUMBER OF ITEMS TO SCROLL
  44. ROWS         BYTE(@ROWS)             !NUMBER OF ROWS TO SCROLL
  45. COLS         BYTE(@COLS)             !NUMBER OF COLUMNS TO SCROLL
  46.  
  47.  
  48.   EJECT
  49.   CODE
  50.   ACTION# = ACTION                 !SAVE ACTION
  51.   OPEN(SCREEN)                     !OPEN THE SCREEN
  52.   SETCURSOR                     !TURN OFF ANY CURSOR
  53.   @SETUP                     !CALL SETUP PROCEDURE
  54.   NDX = 1                     !PUT SELECTOR BAR ON TOP ITEM
  55.   ROW = ROW(?POINT)                 !REMEMBER TOP ROW AND
  56.   COL = COL(?POINT)                 !  LEFT COLUMN OF SCROLL AREA
  57.   tblcol = col
  58.   IF ACTION = 4                     !IF THIS IS A LOOKUP REQUEST
  59.     SET(@KEYNAME,@KEYNAME)             !  FIND IT IN THE FILE
  60.     NEXT(@FILENAME)                 !    AND READ IT
  61.     POINTER# = POINTER(@FILENAME)         !  SAVE POINTER TO CURRENT
  62.     SKIP(@FILENAME,-1)                 !  MAKE IT THE TOP RECORD
  63.     DO SHOW_TABLE                 !  FILL SCROLL AREA
  64.     GET(@FILENAME,POINTER#)             !  AND REFRESH CURRENT RECORD
  65.   ELSE                         !OTHERWISE
  66.     SET(@KEYNAME)                 !  SET TO FIRST RECORD IN FILE
  67.     DO SHOW_TABLE                 !  FILL SCROLL AREA
  68.   .
  69.   RECORDS# = TRUE                 !INITIALIZE RECORDS FLAG
  70.   LOOP                         !LOOP UNTIL USER EXITS
  71.     MAX = RECORDS(@KEYNAME)             !SET LESSER OF FILE RECORD
  72.     IF MAX > COUNT THEN MAX = COUNT.         !  COUNT AND SCROLL ITEM COUNT
  73.     ACTION = ACTION#                 !RESTORE ACTION
  74.     POINTER# = 0                 !CLEAR ADD POINTER
  75.     @LOOKUPS                     !DISPLAY FROM OTHER FILES
  76.     @SHOW                     !DISPLAY STRING VARIABLES
  77.     @COMPUTE                     !DISPLAY COMPUTED FIELDS
  78.     @CONDITIONAL
  79.     @RESULT                     !MOVE RESULTING VALUES
  80.     IF ~RECORDS(@KEYNAME)             !IF THERE ARE NO RECORDS
  81.       CLEAR(@PRE:RECORD)             !  CLEAR RECORD AREA
  82.       ACTION = 1                 !  SET ACTION TO ADD
  83.       tblrow = row(?point)             ! JMC Insert first record
  84.       @AUTONUMKEY
  85.       @UPDATE                     !  CALL FORM FOR FIRST RECORD
  86.       @AUTONUMESC
  87.       IF ~RECORDS(@KEYNAME) THEN BREAK.         !  IF ADD ABORTED THEN EXIT
  88.       SET(@KEYNAME)                 !  SET TO NEW RECORD
  89.       DO SHOW_TABLE                 !  FILL SCROLL AREA
  90.       NDX = 1                     !  PUT SELECTOR BAR ON TOP ITEM
  91.       MAX = 1                     !  MAXIMUM DISPLAYED IS 1
  92.     .                         !
  93.     ALERT                     !RESET ALERTED KEYS
  94.     ALERT(REJECT_KEY)                 !ALERT SCREEN REJECT KEY
  95.     ALERT(ACCEPT_KEY)                 !ALERT SCREEN ACCEPT KEY
  96. !                 network model block added 09/15/88 by dmc
  97. !                 adds <ctrl_e> to table for edit during lookup
  98.            ALERT (CTRL_E)
  99. !                 end block added 09/15/88 by dmc
  100.  
  101. !                 network model block added 09/28/88 by dmc
  102. !                 adds <ctrl_l> to table for auto-locate
  103.            ALERT (CTRL_L)
  104. !                 end block added 09/28/88 by dmc
  105.     @ALERT                     !ALERT HOT KEY
  106.     ACCEPT                     !READ A FIELD
  107.     @TABLEHOT                     !ON HOT KEY, CALL PROCEDURE
  108.     IF KEYCODE() = REJECT_KEY THEN BREAK.     !RETURN ON SCREEN REJECT KEY
  109.     EDIT_RANGE# = FIELD()             !SET ONE FIELD EDIT RANGE
  110.     IF KEYCODE() = ACCEPT_KEY             !ON SCREEN ACCEPT KEY
  111.       UPDATE                     !  MOVE ALL FIELDS FROM SCREEN
  112.       EDIT_RANGE# = ?POINT - 1             !  AND EDIT REMAINING FIELDS
  113.       SELECT(?POINT)                 !  IF OK THEN START HERE NEXT
  114.     .                         !
  115.  
  116.     LOOP FIELD# = FIELD() TO EDIT_RANGE#     !EDIT FIELDS IN THE EDIT RANGE
  117.  
  118.       CASE FIELD#                 !JUMP TO FIELD EDIT ROUTINE
  119.       OF ?FIRST_FIELD                 !FROM THE FIRST FIELD
  120.     IF KEYCODE() = ESC_KEY    OR |         !  RETURN ON ESC KEY
  121.        RECORDS# = FALSE             !  OR NO RECORDS
  122.          FREE(TABLE)             !    FREE THE MEMORY TABLE
  123.          RETURN
  124.     .
  125.       @EDITS                     !EDIT ROUTINES GO HERE
  126.     RECORDS# = TRUE                 !  ASSUME RECORDS ARE HERE
  127.       @INITLOCATE                 !SHOW CURSOR FOR LOCATOR
  128.       OF ?POINT                     !FROM THE POINT FIELD
  129.     CASE KEYCODE()                 !  PROCESS THE KEYSTROKE
  130.  
  131.     OF INS_KEY                 !INSERT KEY
  132.       action = 1
  133.       CLEAR(@PRE:RECORD)             !  CLEAR RECORD AREA
  134.         if records(table) >= count
  135.           tblrow = (count + row) -1
  136.         else
  137.           tblrow = records(table)+row
  138.         .
  139.  
  140.       @AUTONUMKEY
  141.       @UPDATE                 !  CALL FORM FOR NEW RECORD
  142.       @AUTONUMESC
  143.       IF ~ACTION                 !  IF A NEW RECORD WAS ADDED
  144.         POINTER# = POINTER(@FILENAME)     !    REMEMBER WHICH RECORD
  145.         SET(@KEYNAME,@KEYNAME)         !    SET TO NEW RECORD AND
  146.         SKIP(@FILENAME,-1)             !    MAKE IT THE TOP ITEM
  147.         DO SHOW_TABLE             !    DISPLAY THAT PAGE
  148.       .
  149.     OF ENTER_KEY                 !ENTER KEY OR
  150.     OROF ACCEPT_KEY                 !CTRL ENTER KEY
  151.       DO GET_RECORD                 !  READ THE SELECTED RECORD
  152.       IF ERROR()                 !  IF RECORD HAS BEEN DELETED
  153.         MEM:MESSAGE = ERROR()         !    TELL USER WHAT HAPPENED
  154.         SELECT(?)                 !    STAY IN THE POINT FIELD
  155.         DO SHOW_TABLE             !    SHOW IT
  156.         BREAK                 !    AND GET ANOTHER KEY
  157.       .
  158.       IF ACTION = 4                 !  IF THIS IS A LOOKUP REQUEST
  159.         ACTION = 0                 !    SET ACTION TO COMPLETE
  160.         FREE(TABLE)                 !    FREE THE MEMORY TABLE
  161.         RETURN                 !    AND RETURN TO CALLER
  162.       .                     !
  163.       ACTION = 2                 !  SET ACTION TO CHANGE
  164.       tblrow = row(?point)
  165.       @UPDATE                 !  CALL FORM TO CHANGE RECORD
  166.       IF ~ACTION                 !  IF THE RECORD WAS CHANGED
  167.         POINTER# = POINTER(@FILENAME)     !    REMEMBER WHICH RECORD
  168.         SET(@KEYNAME,@KEYNAME)         !    SET TO CHANGED RECORD
  169.         SKIP(@FILENAME,-1)             !    MAKE IT THE TOP ITEM
  170.         DO SHOW_TABLE             !    AND DISPLAY THAT PAGE
  171.       .
  172. !                 network model block added 09/15/88 by dmc
  173. !                 adds <ctrl_e> to table for edit during lookup
  174.          OF CTRL_E             !ctrl-e key
  175.            DO GET_RECORD         !read the selected record
  176.            ACTION# = ACTION         !save action
  177.            ACTION = 2             !set action to change
  178.            tblrow = row(?point)
  179.            @UPDATE             !CALL FORM TO CHANGE RE
  180.            IF ~ACTION             !if the record was changed
  181.              POINTER# = POINTER(@FILENAME)    !remember which record
  182.              SET(@KEYNAME,@KEYNAME)     !set to changed record
  183.              SKIP(@FILENAME,-1)         !make it the top item
  184.              DO SHOW_TABLE         !and display that page
  185.            ELSE                 !otherwise
  186.              SKIP(@FILENAME,(MAX-NDX))     !skip back to same page
  187.            .
  188.            ACTION = ACTION#         !restore action
  189. !                 end block added 09/15/88 by dmc
  190.  
  191.  
  192.     OF DEL_KEY                 !DELETE KEY
  193.       DO GET_RECORD                 !  READ THE SELECTED RECORD
  194.       IF ERROR()                 !  IF RECORD HAS BEEN DELETED
  195.         MEM:MESSAGE = ERROR()         !    TELL USER WHAT HAPPENED
  196.         SELECT(?)                 !    STAY IN THE POINT FIELD
  197.         DO SHOW_TABLE             !    SHOW IT
  198.         BREAK                 !    AND GET ANOTHER KEY
  199.       .
  200.       ACTION = 3                 !  SET ACTION TO DELETE
  201.       tblrow = row(?point)
  202.       @UPDATE                 !  CALL FORM TO DELETE RECORD
  203.       IF ~ACTION                 !  IF RECORD WAS DELETED
  204.         SKIP(@FILENAME,-NDX)         !    SET NEXT RECORD ON TOP
  205.         DO SHOW_TABLE             !    AND DISPLAY THAT PAGE
  206.       .
  207.     OF DOWN_KEY                 !DOWN ARROW KEY
  208.       IF NOT EOF(@FILENAME)             !  IF THERE ARE MORE RECORDS
  209.         SCROLL(ROW,COL,ROWS,COLS,ROWS(?POINT)) !  SCROLL THE SCREEN UP
  210.         NEXT(@FILENAME)             !    READ THE BOTTOM RECORD
  211.         GET(TABLE,1)             !    GET THE TOP POINTER
  212.         DELETE(TABLE)             !    REMOVE TOP ITEM
  213.         TBLPTR = POINTER(@FILENAME)         !    DETERMINE RECORD POINTER
  214.         ADD(TABLE)                 !    ADD TO BOTTOM OF TABLE
  215.         DO SHOW_RECORD             !    AND DISPLAY IT
  216.       .
  217.     OF PGDN_KEY                 !PAGE DOWN KEY
  218.       IF EOF(@FILENAME)             !  ON THE LAST PAGE
  219.         NDX = MAX                 !    POINT TO BOTTOM ITEM
  220.       ELSE                     !  OTHERWISE
  221.         DO SHOW_TABLE             !    DISPLAY NEXT PAGE
  222.       .
  223.     OF CTRL_PGDN                 !CTRL-PAGE DOWN KEY
  224.       NDX = MAX                 !  POINT TO BOTTOM ITEM
  225.       IF NOT EOF(@FILENAME)             !  ON THE LAST PAGE
  226.         SET(@KEYNAME)             !    SET TO BOTTOM RECORD MINUS
  227.         SKIP(@FILENAME,-COUNT)         !    ONE PAGE OF RECORDS
  228.         DO SHOW_TABLE             !    DISPLAY THE LAST PAGE
  229.       .
  230.     OF UP_KEY                 !UP ARROW KEY
  231.       SKIP(@FILENAME,-(COUNT-1))         !  SET TO TOP RECORD MINUS ONE
  232.       IF NOT BOF(@FILENAME)             !  IF THERE IS A PRIOR RECORD
  233.         SCROLL(ROW,COL,ROWS,COLS,-(ROWS(?POINT))) ! SCROLL THE SCREEN DOWN
  234.         PREVIOUS(@FILENAME)             !     READ THE TOP RECORD
  235.         GET(TABLE,RECORDS(TABLE))         !    GET THE LAST POINTER
  236.         DELETE(TABLE)             !    REMOVE LAST ITEM
  237.         TBLPTR = POINTER(@FILENAME)         !    DETERMINE RECORD POINTER
  238.         ADD(TABLE,1)             !    ADD TO TOP OF TABLE
  239.         DO SHOW_RECORD             !     AND DISPLAY IT
  240.       .
  241.       SKIP(@FILENAME,COUNT-1)         !  SET RECORD FOR NEXT PAGE
  242.  
  243.     OF PGUP_KEY                 !PAGE UP KEY
  244.       SKIP(@FILENAME,-(COUNT-1))         !  SET TO TOP RECORD MINUS ONE
  245.       IF BOF(@FILENAME)             !  IF THERE IS NO PRIOR RECORD
  246.         NDX = 1                 !    THEN POINT TO TOP ITEM
  247.         SKIP(@FILENAME,COUNT-1)         !    SET RECORD FOR THIS PAGE
  248.       ELSE                     !  OTHERWISE
  249.         SKIP(@FILENAME,-(COUNT+1))         !    SET RECORD FOR PRIOR PAGE
  250.         DO SHOW_TABLE             !    AND DISPLAY THE PAGE
  251.       .
  252.     OF CTRL_PGUP                 !CTRL-PAGE UP KEY
  253.       SET(@KEYNAME)                 !  SET TO FIRST RECORD
  254.       NDX = 1                 !  POINT TO TOP ITEM
  255.       DO SHOW_TABLE                 !  AND DISPLAY THE PAGE
  256.     .
  257.     @LOCATE
  258.   . . .
  259.   FREE(TABLE)                     !FREE THE MEMORY TABLE
  260.   RETURN                     !RETURN TO CALLER
  261.  
  262. SHOW_TABLE ROUTINE                 !DISPLAY A PAGE OF RECORDS
  263.   FREE(TABLE)                     !  FREE THE MEMORY TABLE
  264.   SKIP(@FILENAME,COUNT-1)             !  SET TO THE BOTTOM RECORD
  265.   IF EOF(@FILENAME)                 !  FOR A PARTIAL PAGE
  266.     SET(@KEYNAME)                 !    SET TO THE LAST RECORD
  267.     SKIP(@FILENAME,-COUNT)             !    AND BACK UP ONE PAGE
  268.   ELSE                         !  OTHERWISE
  269.     SKIP(@FILENAME,-(COUNT-1))             !    SET RECORD FOR THIS PAGE
  270.   .
  271.   NDX# = NDX                     !  SAVE REPEAT INDEX
  272.   LOOP NDX = 1 TO COUNT                 !  LOOP THRU THE SCROLL AREA
  273.     IF EOF(@FILENAME) THEN BREAK.         !    BREAK ON END OF FILE
  274.     NEXT(@FILENAME)                 !    READ THE NEXT RECORD
  275.     TBLPTR = POINTER(@FILENAME)             !    GET THE RECORD NUMBER
  276.     ADD(TABLE)                     !    ADD IT TO THE TABLE
  277.     DO SHOW_RECORD                 !    AND DISPLAY IT
  278.     IF POINTER(@FILENAME) = POINTER# THEN NDX# = NDX.!POINT TO CORRECT RECORD
  279.   .
  280.   NDX = NDX#                     !  RESTORE REPEAT INDEX
  281.   CLEAR(@PRE:RECORD)                 !  CLEAR RECORD AREA
  282.   IF RECORDS(@FILENAME) < COUNT             !  IF RECORDS DO NOT FILL
  283.      NDX#= RECORDS(@FILENAME) * @PROWS         !     GET NUMBER TIMES SIZE
  284.      BLANK(ROW + NDX#,COL,ROWS-NDX#,COLS)     !     BLANK REMAINING AREA
  285.   .
  286.  
  287. SHOW_RECORD ROUTINE                 !DISPLAY A RECORD
  288.   @LOOKUPSCROLL                     !  DISPLAY FROM OTHER FILES
  289.   @SHOWSCROLL                     !  DISPLAY STRING VARIABLES
  290.   @COMPUTESCROLL                 !  DISPLAY COMPUTED FIELDS
  291.  
  292. GET_RECORD ROUTINE                 !READ SELECTED RECORD
  293.   GET(TABLE,NDX)                 !  GET THE TABLE RECORD
  294.   GET(@FILENAME,TBLPTR)                 !  GET THIS RECORD
  295.  
  296. FIND_RECORD ROUTINE                 !LOCATE REQUESTED RECORD
  297.   SET(@KEYNAME,@KEYNAME)             !  SET TO REQUESTED RECORD
  298.   IF EOF(@FILENAME)                 !  IF BEYOND END OF FILE
  299.     PREVIOUS(@FILENAME)                 !    GET THE LAST RECORD
  300.   ELSE                         !  ELSE
  301.     NEXT(@FILENAME)                 !    READ THIS RECORD
  302.   .
  303.   POINTER# = POINTER(@FILENAME)             !  SAVE ITS RECORD POINTER
  304.   SKIP(@FILENAME,-1)                 !  MAKE IT THE TOP RECORD
  305.   DO SHOW_TABLE                     !  AND FILL THE SCROLL AREA
  306.  
  307. SAME_PAGE ROUTINE                 !SET TO SAME PAGE ROUTINE
  308.   SKIP(@FILENAME,-NDX)                 !  SKIP TO TOP OF SAME PAGE
  309.  
  310.  
  311.  
  312. *SELTABLE1**********************************************************************
  313. @PROCNAME    PROCEDURE
  314.  
  315. !     ╔═════════════════════════════════════════════════════════╗
  316. !     ║                                ║
  317. !     ║                                ║
  318. !     ║      06-15-89  John Crenshaw - EAS Technologies        ║
  319. !     ║            Louisville, KY.   502-473-1000        ║
  320. !     ║                                ║
  321. !     ║      06-23-89  Modified for 2008  JC            ║
  322. !     ║                                ║
  323. !     ║                                ║
  324. !     ║                                ║
  325. !     ║      Table 1   Calculates and passes current table row and ║
  326. !     ║            col to a form generated with the FORMTBL    ║
  327. !     ║            model. The variables TBLROW and TBLCOL(byte)║
  328. !     ║            must have been declared earlier.  I suggest ║
  329. !     ║            that you edit the global model and use it    ║
  330. !     ║            to declare the 2 variables.            ║
  331. !     ║                                ║
  332. !     ╚═════════════════════════════════════════════════════════╝
  333.  
  334.  
  335. SCREEN         SCREEN      PRE(SCR),@SCREENOPT
  336.               @PAINTS
  337.               @STRINGS
  338.               @VARIABLES
  339.               ENTRY,USE(?FIRST_FIELD)
  340.               @FIELDS
  341.               @PREPOINT
  342.               REPEAT(@COUNT),EVERY(@PROWS),INDEX(NDX)
  343.           @PLOC        POINT(@PROWS,@COLS),USE(?POINT),ESC(?-1)
  344.                 @SCROLLVARIABLES
  345.          .          .
  346.  
  347. PTR         LONG                 !ENTRY POINTER FOR KEY TABLE
  348. NDX         BYTE                 !REPEAT INDEX FOR POINT AREA
  349. ROW         BYTE                 !ACTUAL ROW OF SCROLL AREA
  350. COL         BYTE                 !ACTUAL COLUMN OF SCROLL AREA
  351. COUNT         BYTE(@COUNT)             !NUMBER OF ITEMS TO SCROLL
  352. ROWS         BYTE(@ROWS)             !NUMBER OF ROWS TO SCROLL
  353. COLS         BYTE(@COLS)             !NUMBER OF COLUMNS TO SCROLL
  354.  
  355. TABLE         TABLE                 !TABLE OF RECORD KEYS
  356. TBLPTR           LONG                 !  POINTER TO DATA RECORD
  357. KEY           GROUP,PRE(TBL)             !  RECORD KEY FIELDS
  358.          @COMPONENTS
  359.          . .
  360. @SAVEITEMS
  361.  
  362.   EJECT
  363.   CODE
  364.   ACTION# = ACTION                 !SAVE ACTION
  365.   OPEN(SCREEN)                     !OPEN THE SCREEN
  366.   SETCURSOR                     !TURN OFF ANY CURSOR
  367.   @SETUP                     !CALL SETUP PROCEDURE
  368.   @INITSELECTS                     !SAVE SELECTOR FIELDS
  369.   PTR = 1                     !START AT TABLE ENTRY
  370.   NDX = 1                     !PUT SELECTOR BAR ON TOP ITEM
  371.   ROW = ROW(?POINT)                 !REMEMBER TOP ROW AND
  372.   COL = COL(?POINT)                 !  LEFT COLUMN OF SCROLL AREA
  373.   tblcol = col
  374.   RECORDS# = TRUE                 !INITIALIZE RECORDS FLAG
  375.   LOOP                         !LOOP UNTIL USER EXITS
  376.     ACTION = ACTION#                 !RESTORE ACTION
  377.     @RESTSELECTS                 !RESTORE SELECTOR FIELDS
  378.     @LOOKUPS                     !DISPLAY FROM OTHER FILES
  379.     @SHOW                     !DISPLAY STRING VARIABLES
  380.     @COMPUTE                     !DISPLAY COMPUTED FIELDS
  381.     @CONDITIONAL
  382.     @RESULT                     !MOVE RESULTING VALUES
  383.     ALERT                     !RESET ALERTED KEYS
  384.     ALERT(REJECT_KEY)                 !ALERT SCREEN REJECT KEY
  385.     ALERT(ACCEPT_KEY)                 !ALERT SCREEN ACCEPT KEY
  386.     @ALERT                     !ALERT HOT KEY
  387.     ACCEPT                     !READ A FIELD
  388.     MEM:MESSAGE = ''                 !CLEAR MESSAGE AREA
  389.     @TABLEHOT                     !ON HOT KEY, CALL PROCEDURE
  390.     IF KEYCODE() = REJECT_KEY THEN BREAK.     !RETURN ON SCREEN REJECT KEY
  391.  
  392.     EDIT_RANGE# = FIELD()             !SET ONE FIELD EDIT RANGE
  393.     IF KEYCODE() = ACCEPT_KEY             !ON SCREEN ACCEPT KEY
  394.       UPDATE                     !  MOVE ALL FIELDS FROM SCREEN
  395.       EDIT_RANGE# = ?POINT - 1             !  AND EDIT REMAINING FIELDS
  396.       SELECT(?POINT)                 !  IF OK THEN START HERE NEXT
  397.     .                         !
  398.  
  399.     LOOP FIELD# = FIELD() TO EDIT_RANGE#     !EDIT FIELDS IN THE EDIT RANGE
  400.  
  401.       CASE FIELD#                 !JUMP TO FIELD EDIT ROUTINE
  402.  
  403.       OF ?FIRST_FIELD                 !FROM THE FIRST FIELD
  404.     IF KEYCODE() = ESC_KEY OR |         !  RETURN ON ESC KEY
  405.        RECORDS# = FALSE             !  OR NO RECORDS
  406.          FREE(TABLE)             !  FREE THE TABLE OF POINTS
  407.          RETURN                 !  RETURN TO CALLER
  408.     .
  409.       @EDITS                     !EDIT ROUTINES GO HERE
  410.     RECORDS# = TRUE                 !  ASSUME THERE ARE RECORDS
  411.       @INITLOCATE
  412.       OF ?POINT                     !PROCESS THE POINT FIELD
  413.     IF ~RECORDS(TABLE)             !IF THERE ARE NO RECORDS
  414.       CLEAR(@PRE:RECORD)             !  CLEAR RECORD AREA
  415.       ACTION = 1                 !  SET ACTION TO ADD
  416.       @AUTONUMKEY
  417.       UPDATE                 !  UPDATE ALL FIELDS
  418.       tblrow = row(?point)
  419.       @UPDATE                 !  CALL FORM FOR FIRST RECORD
  420.       IF ~ACTION                 !  IF RECORD WAS ADDED
  421.         DO ADD_TABLE             !    THEN ADD NEW TABLE ENTRY
  422.         DO SORT_TABLE             !    SORT THE TABLE
  423.         DO SHOW_TABLE             !    AND DISPLAY FIRST PAGE
  424.       .
  425.       IF ~RECORDS(TABLE)             !  IF ADD ABORTED TRY AGAIN
  426.           RECORDS# = FALSE             !    INDICATE NO RECORDS
  427.           SELECT(?-1)             !    SELECT PREVIOUS FIELD
  428.           BREAK                 !    END THE EDITS
  429.       .
  430.       CYCLE                     !  CONTINUE THE EDIT
  431.     .
  432.     CASE KEYCODE()                 !PROCESS THE KEYSTROKE
  433.  
  434.     OF ENTER_KEY                 !ENTER KEY OR
  435.     OROF ACCEPT_KEY                 !CTRL-ENTER KEY
  436.       DO GET_RECORD                 !  READ THE SELECTED RECORD
  437.       IF ERROR()                 !  IF RECORD HAS BEEN DELETED
  438.         MEM:MESSAGE = ERROR()         !    TELL USER WHAT HAPPENED
  439.         SELECT(?)                 !    STAY IN THE POINT FIELD
  440.         DO BUILD_TABLE             !    REBUILD TABLE
  441.         DO SORT_TABLE             !    SORT IT
  442.         DO SHOW_TABLE             !    SHOW IT
  443.         BREAK                 !    AND GET ANOTHER KEY
  444.       .
  445.       IF ACTION = 4     AND KEYCODE() = ENTER_KEY ! IF THIS IS A LOOKUP REQUEST
  446.         ACTION = 0                 !    SET ACTION TO COMPLETE
  447.         FREE(TABLE)                 !    FREE THE TABLE OF POINTS
  448.         RETURN                 !    RETURN TO CALLER
  449.       .
  450.       ACTION = 2                 !  SET ACTION TO CHANGE
  451.       tblrow=row(?point)
  452.       @UPDATE                 !  CALL FORM TO CHANGE RECORD
  453.       IF ~ACTION                 !  IF THE RECORD WAS CHANGED
  454.         DELETE(TABLE)             !    DELETE OLD TABLE ENTRY
  455.         DO ADD_TABLE             !    ADD NEW TABLE ENTRY
  456.         DO SORT_TABLE             !    SORT THE TABLE
  457.         DO SHOW_TABLE             !    AND DISPLAY THAT PAGE
  458.       .
  459.     OF INS_KEY                 !INS KEY
  460.       CLEAR(@PRE:RECORD)             !  CLEAR RECORD AREA
  461.       ACTION = 1                 !  SET ACTION TO ADD
  462.       if records(table) >= count
  463.         tblrow = (count + row) -1
  464.       else
  465.         tblrow = records(table) + row
  466.       .
  467.       @AUTONUMKEY
  468.       @UPDATE                 !  CALL FORM TO CHANGE RECORD
  469.       IF ~ACTION                 !  IF RECORD WAS ADDED
  470.         DO ADD_TABLE             !    ADD NEW TABLE ENTRY
  471.         DO SORT_TABLE             !    SORT THE TABLE
  472.         DO SHOW_TABLE             !    AND DISPLAY THAT PAGE
  473.       .
  474.     OF DEL_KEY                 !DEL KEY
  475.       DO GET_RECORD                 !  READ THE SELECTED RECORD
  476.       IF ERROR()                 !  IF RECORD HAS BEEN DELETED
  477.         MEM:MESSAGE = ERROR()         !    TELL USER WHAT HAPPENED
  478.         SELECT(?)                 !    STAY ON THE POINT FIELD
  479.         DO BUILD_TABLE             !    REBUILD TABLE
  480.         DO SORT_TABLE             !    SORT IT
  481.         DO SHOW_TABLE             !    SHOW IT
  482.         BREAK                 !    AND GET ANOTHER KEY
  483.       .
  484.       ACTION = 3                 !  SET ACTION TO DELETE
  485.       tblrow = row(?point)
  486.       @UPDATE                 !  CALL FORM TO DELETE RECORD
  487.       IF ~ACTION                 !  IF RECORD WAS DELETED
  488.         DELETE(TABLE)             !    DELETE TABLE ENTRY
  489.         DO SHOW_TABLE             !    AND DISPLAY THAT PAGE
  490.       .
  491.     OF DOWN_KEY                 !DOWN ARROW KEY
  492.       IF PTR <= RECORDS(TABLE)-COUNT     !  IF THERE ARE MORE ENTRIES
  493.         SCROLL(ROW,COL,ROWS,COLS,ROWS(?POINT)) !  SCROLL THE SCREEN UP
  494.         PTR += 1                 !    SET TO THE NEXT ENTRY
  495.         DO SHOW_RECORD             !    AND DISPLAY THE RECORD
  496.       .
  497.     OF PGDN_KEY                 !PAGE DOWN KEY
  498.       IF PTR >= RECORDS(TABLE)-COUNT+1     !  ON THE LAST PAGE
  499.         NDX = COUNT.             !    POINT TO BOTTOM ITEM
  500.       PTR += COUNT                 !  OTHERWISE
  501.       TBLPTR = -1                 !INITIALIZE TO NO RECORD
  502.       DO SHOW_TABLE                 !    DISPLAY THE NEXT PAGE
  503.  
  504.     OF CTRL_PGDN                 !CTRL-PAGE DOWN KEY
  505.       PTR = RECORDS(TABLE) - COUNT + 1     !  SET TO LAST PAGE
  506.       NDX = COUNT                 !  POINT TO BOTTOM ITEM
  507.       TBLPTR = -1                 !INITIALIZE TO NO RECORD
  508.       DO SHOW_TABLE                 !  DISPLAY THE LAST PAGE
  509.  
  510.     OF UP_KEY                 !UP ARROW KEY
  511.       IF PTR > 1                 !  IF THERE IS A PRIOR RECORD
  512.         PTR -= 1                 !    SET TO PRIOR RECORD
  513.         SCROLL(ROW,COL,ROWS,COLS,-(ROWS(?POINT)))! SCROLL THE SCREEN DOWN
  514.         DO SHOW_RECORD             !    DISPLAY THE RECORD
  515.       .
  516.     OF PGUP_KEY                 !PAGE UP KEY
  517.       IF PTR = 1 THEN NDX = 1.         !  ON FIRST PAGE POINT TO TOP
  518.       PTR -= ROWS                 !  OTHERWISE BACK UP 1 PAGE
  519.       TBLPTR = -1                 !INITIALIZE TO NO RECORD
  520.       DO SHOW_TABLE                 !  AND DISPLAY IT
  521.  
  522.     OF CTRL_PGUP                 !CTRL-PAGE UP
  523.       PTR = 1                 !  POINT TO FIRST RECORD
  524.       NDX = 1                 !  POINT TO TOP ITEM
  525.       TBLPTR = -1                 !INITIALIZE TO NO RECORD
  526.       DO SHOW_TABLE                 !  AND DISPLAY THE FIRST PAGE
  527.     .
  528.     @LOCATE
  529.   . . .                         !
  530.  
  531.   FREE(TABLE)                     !FREE MEMORY TABLE
  532.   RETURN                     !AND RETURN TO CALLER
  533.  
  534. BUILD_TABLE ROUTINE                 !BUILD MEMORY TABLE
  535.   FREE(TABLE)                     !EMPTY THE TABLE
  536.   CLEAR(@PRE:REcoRD)
  537.   @RESTSELECTS
  538.   UPDATE
  539.   @RESULT
  540.   @READTABLE                     !DO SELECTOR OR FILTER
  541.   TBLPTR = -1                     !INITIALIZE TO NO RECORD
  542.   DO SHOW_TABLE                     !DISPLAY A PAGE OF RECORDS
  543.  
  544. ADD_TABLE ROUTINE                 !ADD ENTRY TO MEMORY TABLE
  545.   @CHECKADD                     !
  546.   IF ~(@FILTER) THEN EXIT.             !  EXIT IF FILTERED OUT
  547.   @SETCOMPONENTS                 !  MOVE KEY COMPONENTS
  548.   TBLPTR = POINTER(@FILENAME)             !  SAVE DATA RECORD POINTER
  549.   ADD(TABLE)                     !  ADD NEW TABLE ENTRY
  550.   IF ERROR()                     !  IF OUT OF MEMORY
  551.     MEM:MESSAGE = ERROR()             !    INFORM USER
  552.     BEEP                     !    SOUND ALARM
  553.   .
  554. SORT_TABLE ROUTINE                 !SORT TABLE ENTRIES
  555.   TBLPTR# = TBLPTR                 !  SAVE DATA RECORD POINTER
  556.   @SORTTABLE                     !  SORT THE TABLE
  557.   LOOP PTR = 1 TO RECORDS(TABLE)         !  LOOK UP THE SAVED POINTER
  558.     GET(TABLE,PTR)                 !    SO WE WILL STILL POINT
  559.     IF TBLPTR = TBLPTR# THEN EXIT.         !    AT THE SAME RECORD
  560.   .
  561.  
  562. SHOW_TABLE ROUTINE                 !DISPLAY A PAGE OF RECORDS
  563.   IF PTR > RECORDS(TABLE)-COUNT+1         !  FOR A PARTIAL PAGE
  564.     PTR = RECORDS(TABLE)-COUNT+1.         !    SET TO THE LAST RECORD
  565.   IF PTR < 1 THEN PTR = 1.             !    AND BACK UP ONE PAGE
  566.   TBLPTR# = TBLPTR                 !  SAVE DATA RECORD POINTER
  567.   NDX# = NDX                     !  SAVE REPEAT INDEX
  568.   LOOP NDX = 1 TO COUNT                 !  LOOP THRU THE SCROLL AREA
  569.     DO SHOW_RECORD                 !    DISPLAY A RECORD
  570.     IF TBLPTR# = TBLPTR THEN NDX# = NDX.     !    POINT TO CORRECT RECORD
  571.   .                         !
  572.   NDX = NDX#                     !  RESTORE REPEAT INDEX
  573.   IF NDX > RECORDS(TABLE) THEN NDX = RECORDS(TABLE).!SHOWING THE LAST
  574.   CLEAR(@PRE:RECORD)                 !  CLEAR RECORD AREA
  575.   IF RECORDS(TABLE) < COUNT             !  IF RECORDS DO NOT FILL
  576.      NDX#= RECORDS(TABLE) * @PROWS         !     GET NUMBER TIMES SIZE
  577.      BLANK(ROW + NDX#,COL,ROWS-NDX#,COLS)     !     BLANK REMAINING AREA
  578.   .
  579.  
  580. SHOW_RECORD ROUTINE                 !DISPLAY A RECORD
  581.   TBLPTR = 0                     !  START WITH NO RECORD
  582.   GET(TABLE,PTR+NDX-1)                 !  GET THE TABLE ENTRY
  583.   IF ~ERROR()                     !  IF THERE IS ONE
  584.     GET(@FILENAME,TBLPTR)             !    READ A DATA RECORD
  585.     IF ~ERROR()
  586.       @RESTSELECTS                 !    RESTORE SELECTOR FIELDS
  587.       @LOOKUPSCROLL                 !    DISPLAY FROM OTHER FILES
  588.       @SHOWSCROLL                 !    DISPLAY STRING VARIABLES
  589.       @COMPUTESCROLL                 !    DISPLAY COMPUTED FIELDS
  590.   . .
  591.  
  592. GET_RECORD ROUTINE                 !READ SELECTED RECORD
  593.   GET(TABLE,PTR+NDX-1)                 !  GET THE TABLE ENTRY
  594.   GET(@FILENAME,TBLPTR)                 !  READ THE DATA RECORD
  595.  
  596. FIND_RECORD ROUTINE                 !LOCATE REQUESTED RECORD
  597.   @SETCOMPONENTS                 !  MOVE THEM TO THE TABLE
  598.   GET(TABLE,KEY)                 !  GET THE TABLE ENTRY
  599.   PTR = POINTER(TABLE)                 !  SET RECORD POINTER
  600.   IF ~PTR THEN PTR = RECORDS(TABLE).         !  SET TO LAST IF NO POINTER
  601.   GET(TABLE,PTR)                 !  AND READ THE DATA RECORD
  602.   DO SHOW_TABLE                     !  DISPLAY THAT PAGE
  603.  
  604. SAME_PAGE ROUTINE                 !SET TO SAME PAGE ROUTINE
  605.   DO SORT_TABLE                     !  SORT THE TABLE
  606.  
  607. *FORMTBL************************************************************************
  608. @PROCNAME    PROCEDURE
  609.  
  610.  
  611. !     ╔═════════════════════════════════════════════════════════╗
  612. !     ║                                ║
  613. !     ║                                ║
  614. !     ║      06-15-89  John Crenshaw - EAS Technologies        ║
  615. !     ║            Louisville, KY.   502-473-1000        ║
  616. !     ║                                ║
  617. !     ║      06-23-89  Modified for 2008                ║
  618. !     ║                                ║
  619. !     ║      07-06-89  Fixed bug in model on action 3 in network    ║
  620. !     ║            pointer# is set to 0 giveing a Record    ║
  621. !     ║            not available error.            ║
  622. !     ║                                ║
  623. !     ║                                ║
  624. !     ║                                ║
  625. !     ║        Uses the variables TBLROW and TBLCOL passed    ║
  626. !     ║        from TABLE1, TABLESEL1, and SELTABLE1 to open    ║
  627. !     ║        a from that appears to allow editing on the    ║
  628. !     ║        table.                        ║
  629. !     ║                                ║
  630. !     ╚═════════════════════════════════════════════════════════╝
  631.  
  632.  
  633.  
  634. SCREEN         SCREEN      at(tblrow,tblcol),PRE(SCR),@SCREENOPT
  635.               @PAINTS
  636.               @STRINGS
  637.               @VARIABLES
  638.               ENTRY,USE(?FIRST_FIELD)
  639.               @FIELDS
  640.               @PAUSE
  641.               ENTRY,USE(?LAST_FIELD)
  642.               PAUSE(''),USE(?DELETE_FIELD)
  643.          .
  644.  
  645. SAVE_RECORD  GROUP;BYTE,DIM(SIZE(@PRE:RECORD)).
  646. SAVE_MEMO    GROUP;BYTE,DIM(SIZE(@MEMO)).
  647.  
  648.  
  649. MSG       string(80)
  650.  
  651.   EJECT
  652.   CODE
  653.   OPEN(SCREEN)                     !OPEN THE SCREEN
  654.   SETCURSOR                     !TURN OFF ANY CURSOR
  655. !                 network model block changed 09/15/88 by dmc
  656. !                 moved @setup before save_record & save_memo equates
  657. !                 to solve 'changed by another station' message
  658. !                 display when get(filename,1);action=2
  659. !                 is used to load the single record in a system file
  660. !                 for edit.
  661.   @SETUP                     !CALL SETUP PROCEDURE
  662.   SAVE_RECORD = @PRE:RECORD             !SAVE THE ORIGINAL
  663.   SAVE_MEMO   = @MEMO                 !SAVE THE ORIGINAL
  664. !         END BLOCK CHANGED 09/15/88 BY DMC
  665.   DISPLAY                     !DISPLAY THE FIELDS
  666.   EXECUTE ACTION                 !SET THE CURRENT RECORD POINTER
  667.     POINTER# = 0                 !  NO RECORD FOR ADD
  668.     POINTER# = POINTER(@FILENAME)         !  CURRENT RECORD FOR CHANGE
  669.     POINTER# = POINTER(@FILENAME)         !  CURRENT RECORD FOR CHANGE
  670.   .
  671.   LOOP                         !LOOP THRU ALL THE FIELDS
  672.     MSG = CENTER(clip(MEM:MESSAGE),80) !DISPLAY ACTION MESSAGE
  673.     sethue(4,7)
  674.     show(25,1,msg)
  675.     sethue()
  676.     @LOOKUPS                     !DISPLAY FROM OTHER FILES
  677.     @SHOW                     !DISPLAY STRING VARIABLES
  678.     @COMPUTE                     !DISPLAY COMPUTED FIELDS
  679.     @CONDITIONAL
  680.     @RESULT                     !MOVE RESULTING VALUES
  681.     ALERT                     !RESET ALERTED KEYS
  682.     ALERT(ACCEPT_KEY)                 !ALERT SCREEN ACCEPT KEY
  683.     ALERT(REJECT_KEY)                 !ALERT SCREEN REJECT KEY
  684.     @ALERT                     !ALERT HOT KEY
  685.     ACCEPT                     !READ A FIELD
  686.     @CHECKHOT                     !ON HOT KEY, CALL PROCEDURE
  687.     IF KEYCODE() = REJECT_KEY THEN RETURN.     !RETURN ON SCREEN REJECT KEY
  688.     EXECUTE ACTION                 !SET ACTION MESSAGE
  689.       MEM:MESSAGE = 'Creating New Record'    !
  690.       MEM:MESSAGE = 'Changing Existing Record'       !
  691.       MEM:MESSAGE = 'Press Enter to Delete'     !
  692.     .
  693.     EDIT_RANGE# = FIELD()             !SET ONE FIELD EDIT RANGE
  694.     IF KEYCODE() = ACCEPT_KEY             !ON SCREEN ACCEPT KEY
  695.       UPDATE                     !  MOVE ALL FIELDS FROM SCREEN
  696.       EDIT_RANGE# = FIELDS()             !  AND EDIT REMAINING FIELDS
  697.     .                         !
  698.     LOOP FIELD# = FIELD() TO EDIT_RANGE#     !EDIT FIELDS IN THE EDIT RANGE
  699.       CASE FIELD#                 !JUMP TO FIELD EDIT ROUTINE
  700.       OF ?FIRST_FIELD                 !FROM THE FIRST FIELD
  701.     IF KEYCODE() = ESC_KEY             !  RETURN ON ESC KEY
  702.       msg=all(' ',80)             !JMC blank 25th line
  703.       show(25,1,msg)
  704.       RETURN
  705.     .
  706.     IF ACTION = 3 THEN SELECT(?DELETE_FIELD).!  OR CONFIRM FOR DELETE
  707.  
  708.       @EDITS                     !EDIT ROUTINES GO HERE
  709.       OF ?LAST_FIELD                 !FROM THE LAST FIELD
  710.     IF ACTION = 2 OR ACTION = 3         !IF UPDATEING RECORD
  711.       HOLD(@FILENAME)             !  HOLD FILE
  712.       GET(@FILENAME,POINTER#)         !  RE-READ SAME RECORD
  713.       IF ERRORCODE() = 35             !  IF RECORD WAS DELETED
  714.         IF ACTION = 2
  715.            ACTION = 1
  716.         ELSE                 !
  717.            RELEASE(@FILENAME)         !  RELEASE FILE
  718.            ACTION = 0             !  TURN OFF ACTION
  719.         .
  720.       ELSIF |                 !  IF IT HAS BEEN CHANGED
  721.         @MEMO <> SAVE_MEMO OR |         !
  722.         @PRE:RECORD <> SAVE_RECORD         !    BY ANOTHER STATION
  723.         MEM:MESSAGE = 'CHANGED BY ANOTHER STATION' !INFORM USER
  724.         SELECT(2)                 !  GO BACK TO FIELD 1
  725.         BEEP                 !  SOUND ALARM
  726.         RELEASE(@FILENAME)             !  RELEASE FILE
  727.         SAVE_RECORD = @PRE:RECORD         !  SAVE RECORD
  728.         SAVE_MEMO = @MEMO             !  SAVE MEMO
  729.         DISPLAY                 !  DISPLAY THE FIELDS
  730.         BREAK                 !  AND CONTINUE
  731.       .
  732.       UPDATE                 !UPDATE FROM SCREEN TO RECORD
  733.       @RESULT                 !MOVE RESULTING VALUES
  734.     .
  735.     EXECUTE ACTION                 !  UPDATE THE FILE
  736.       ADD(@FILENAME)             !    ADD NEW RECORD
  737.       PUT(@FILENAME)             !    CHANGE EXISTING RECORD
  738.       DELETE(@FILENAME)             !    DELETE EXISTING RECORD
  739.     .
  740.     if action = 3 or action = 2
  741.       release(@filename)
  742.     .
  743.  
  744.     IF ERROR() THEN STOP(ERROR()).         !  CHECK FOR UNEXPECTED ERROR
  745.     PUT(@FILENAME2)                 !  UPDATE SECONDARY FILES
  746.     PUT(@FILENAME3)                 !  UPDATE SECONDARY FILES
  747.     PUT(@FILENAME4)                 !  UPDATE SECONDARY FILES
  748.     IF ACTION = 1 THEN POINTER# = POINTER(@FILENAME). !POINT TO RECORD
  749.     SAVE_RECORD = @PRE:RECORD         !  NEW ORIGINAL
  750.     SAVE_MEMO   = @MEMO             !  NEW ORIGINAL
  751.     ACTION = ACTION#
  752.     @NEXTFORM                 !  CALL NEXT FORM PROCEDURE
  753.     ACTION = 0                 !  SET ACTION TO COMPLETE
  754.     msg=all(' ',80)                 !JMC blank 25th line
  755.     show(25,1,msg)
  756.     RETURN                     !  AND RETURN TO CALLER
  757.  
  758.       OF ?DELETE_FIELD                 !FROM THE DELETE FIELD
  759.     IF KEYCODE() = ENTER_KEY |         !  ON ENTER KEY
  760.     OR KEYCODE() = ACCEPT_KEY         !  OR CTRL-ENTER KEY
  761.       SELECT(?LAST_FIELD)             !    DELETE THE RECORD
  762.     ELSE                     !  OTHERWISE
  763.       BEEP                     !    BEEP AND ASK AGAIN
  764.   . . . .
  765.