home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / spd_20.zip / CUSTOM3.MDL < prev    next >
Text File  |  1990-04-26  |  90KB  |  2,241 lines

  1. *Global*************************************************************************
  2.          INCLUDE('\CLARION\STD_KEYS.CLA')
  3.          INCLUDE('\CLARION\CTL_KEYS.CLA')
  4.          INCLUDE('\CLARION\ALT_KEYS.CLA')
  5.          INCLUDE('\CLARION\SHF_KEYS.CLA')
  6.  
  7. Reject_Key   EQUATE(Ctrl_Esc)
  8. Accept_Key   EQUATE(Ctrl_Enter)
  9. True         EQUATE(1)
  10. False         EQUATE(0)
  11. eMark         EQUATE('<251>')
  12.  
  13.          MAP
  14.            PROC(G_OPENFILES)
  15.            @RUNMAP
  16.            @Modules
  17.            MODULE('D:\CLARION\ChkErr_')     !!
  18.          PROC(ChkErr)             !!
  19.            .                 !!
  20.            MODULE('DOS1'),BINARY         !!
  21.          PROC(GoDOS)             !!
  22.            .                 !!
  23.            MODULE('PutKbd'),BINARY         !!
  24.          PROC(PutKbd)             !!
  25.            .                 !!
  26.            MODULE('D:\CLARION\NoRecs_')     !!
  27.          PROC(NoRecs)             !!
  28.            .                 !!
  29.            MODULE('D:\CLARION\GDevice_')     !!
  30.          PROC(GetDevice_)         !!
  31.            .                 !!
  32.            MODULE('D:\CLARION\View_')     !!
  33.          PROC(View_)             !!
  34.            .                 !!
  35.            MODULE('D:\CLARION\ShwCncl_')     !!
  36.          PROC(ShowCancel_)         !!
  37.            .                 !!
  38.            MODULE('D:\CLARION\AbortYN_')
  39.          FUNC(AbortEditYN_),STRING
  40.            .
  41.          .
  42.          EJECT('File Layouts')
  43.          @File
  44.          EJECT('Global Memory Variables')
  45.  
  46. Action         SHORT
  47. eDone         EQUATE(0)                 !!0 = No Action
  48. eAdd         EQUATE(1)                 !!1 = Add Record
  49. eChange         EQUATE(2)                 !!2 = Change Record
  50. eDelete         EQUATE(3)                 !!3 = Delete Record
  51. eView         EQUATE(4)                 !!4 = Lookup/View
  52.  
  53.          @Memory
  54.  
  55.          INCLUDE('MEM_VARS.CPY')
  56.  
  57. !                         !!Add This Screen
  58. !  OpenDatScr_    SCREEN         WINDOW(6,25),AT(10,29),HUE(7,1)
  59. !          ROW(6,1)   PAINT(1,1),TRN
  60. !          ROW(1,25)  PAINT(1,1),TRN
  61. !            COL(1)   STRING('╔═<0{20}>═╗'),ENH
  62. !          ROW(2,1)   REPEAT(3);STRING('║<0{22}>║'),ENH .
  63. !          ROW(5,1)   STRING('╚═{22}╝'),ENH
  64. !          ROW(2,25)  REPEAT(4);STRING('░'),HUE(7,0) .
  65. !          ROW(6,2)   STRING('░{24}'),HUE(7,0)
  66. !          ROW(1,3)   STRING(' Opening data files '),HUE(0,3)
  67. !  OpenDatMsg_      ROW(2,2)   STRING(22),ENH,BLK
  68. !  DataFile_      ROW(3,9)   STRING(8),HUE(14,1)
  69. !        .
  70.  
  71.          EJECT('Code Section')
  72.   CODE
  73.   SETHUE(7,0)                     !Set White On Black
  74.   BLANK                         !  And Blank
  75.   HELP(@HELPFILE)                 !OPEN THE HELP FILE
  76.   SETHUE()                     !    The Screen (!!Move Line)
  77.   G_OPENFILES                     !OPEN OR CREATE FILES
  78.   @BaseProc                     !Call The Base Procedure
  79.   RETURN                     !Exit To Dos
  80.  
  81. !===============================================================================
  82. G_OPENFILES  PROCEDURE                 !OPEN FILES & CHECK FOR ERROR
  83.   CODE
  84.   @OPENFILES                     !OPEN EACH FILE
  85.   BLANK                         !BLANK THE SCREEN
  86.  
  87.   @RUNPROC
  88.  
  89. *NormMenu***********************************************************************
  90. @ProcName    PROCEDURE                 !Original Menu Model Proc
  91.  
  92. Screen         SCREEN      PRE(Scr),@ScreenOpt
  93.               @Paints
  94.               @Strings
  95.               @Variables
  96.               ENTRY,USE(?First_Field)
  97.               @Fields
  98.               MENU,USE(Menu_Field),REQ  !!Remove "?" From Use
  99.                 @CHOICES
  100.          .          .
  101.  
  102. Menu_Field   STRING(80)                 !!Add This Varible
  103.  
  104.   EJECT
  105.   CODE
  106.   OPEN(Screen)                     !Open The Menu Screen
  107.   SETCURSOR                     !Turn Off Any Cursor
  108.   @Setup                     !Call Setup Procedure
  109.   LOOP                         !Loop Until User Exits
  110.     @Lookups                     !Display From Other Files
  111.     @Show                     !Display String Variables
  112.     @Compute                     !Display Computed Fields
  113.     @Conditional                 !Display Conditional Fields
  114.     @Result                     !Move Resulting Values
  115.     ALERT                     !Turn Off All Alerted Keys
  116.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  117.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  118.     @Alert                     !Alert Hot Keys
  119.     ACCEPT                     !Read A Field Or Menu Choice
  120.     @CheckHot                     !On Hot Key, Call Procedure
  121.     IF KEYCODE() = Reject_Key THEN RETURN.     !Return On Screen Reject
  122.  
  123.     Edit_Range# = FIELD()             !Set One Field Edit Range
  124.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  125.       UPDATE                     !  Move All Fields From Screen
  126.       Edit_Range# = ?Menu_Field - 1         !  And Edit Remaining Fields
  127.       SELECT(?Menu_Field)             !  If Ok Then Start Here Next
  128.     .                         !
  129.  
  130.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  131.  
  132.       CASE Field#                 !Jump To Field Edit Routine
  133.       OF ?First_Field                 !From The First Field
  134.     IF KEYCODE() = Esc_Key THEN RETURN.     !  Return On Esc Key
  135.  
  136.       @Edits                     !Edit Routines Go Here
  137.       OF ?Menu_Field                 !From The Menu Field
  138.     EXECUTE CHOICE()             !  Call The Selected Procedure
  139.       @Menu                     !
  140.   . . . .
  141. *Menu***************************************************************************
  142. @ProcName    PROCEDURE                 !!New Menu Model Procedure
  143.  
  144. Screen         SCREEN      PRE(Scr),@ScreenOpt
  145.               @Paints
  146.               @Strings
  147.               @Variables
  148.               ENTRY,USE(?First_Field)
  149.               @Fields
  150.               MENU,USE(Menu_Field),REQ  !!Remove "?" From Use
  151.                 @CHOICES
  152.          .          .
  153.  
  154. Menu_Field   STRING(80)                 !!Add This Variable
  155.  
  156.   EJECT
  157.   CODE
  158.   OPEN(Screen)                     !Open The Menu Screen
  159.   SETCURSOR                     !Turn Off Any Cursor
  160.   @Setup                     !Call Setup Procedure
  161.   LOOP                         !Loop Until User Exits
  162.     @Lookups                     !Display From Other Files
  163.     @Show                     !Display String Variables
  164.     @Compute                     !Display Computed Fields
  165.     @Conditional                 !Display Conditional Fields
  166.     @Result                     !Move Resulting Values
  167.     ALERT                     !Turn Off All Alerted Keys
  168.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  169.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  170.     ALERT(Tab_Key)                 !!Alert Tab Key
  171.     ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  172.     @Alert                     !Alert Hot Keys
  173.     ACCEPT                     !Read A Field Or Menu Choice
  174.     @CheckHot                     !On Hot Key, Call Procedure
  175.     IF KEYCODE() = Reject_Key             !!If Reject Key Pressed
  176.       RETURN                     !!  Return
  177.     ELSIF KEYCODE() = Shft_Tab    |         !!Elsif Shft_Tab Pressed
  178.     AND FIELD() ~= ?First_Field             !!And Not First Field
  179.       UPDATE(?)                     !!  Update Current Field
  180.       SELECT(?-1)                 !!  Go Back One Field
  181.     ELSIF KEYCODE() = Tab_Key             !!Elsif Tab Key Pressed
  182.       UPDATE(?)                     !!  Update Current Field
  183.     .                         !!.
  184.  
  185.     Edit_Range# = FIELD()             !Set One Field Edit Range
  186.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  187.       UPDATE                     !  Move All Fields From Screen
  188.       Edit_Range# = ?Menu_Field - 1         !  And Edit Remaining Fields
  189.       SELECT(?Menu_Field)             !  If Ok Then Start Here Next
  190.     .                         !
  191.  
  192.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  193.  
  194.       CASE Field#                 !Jump To Field Edit Routine
  195.       OF ?First_Field                 !From The First Field
  196.     IF KEYCODE() = Esc_Key THEN RETURN.     !  Return On Esc Key
  197.  
  198.       @Edits                     !Edit Routines Go Here
  199.       OF ?Menu_Field                 !From The Menu Field
  200.     EXECUTE CHOICE()             !  Call The Selected Procedure
  201.       @Menu                     !
  202.   . . . .
  203. *MainMenu***********************************************************************
  204. @ProcName    PROCEDURE                 !!This Is A New Modified Proc
  205.  
  206. Screen         SCREEN      PRE(Scr),@ScreenOpt
  207.               @Paints
  208.               @Strings
  209.               @Variables
  210.               ENTRY,USE(?First_Field)
  211.               @Fields
  212.               MENU,USE(Menu_Field),REQ  !!Remove "?" From Use
  213.                 @Choices
  214.          .          .
  215.  
  216. Menu_Field   STRING(80)                 !!Add This Variable
  217.  
  218.   EJECT
  219.   CODE
  220.   OPEN(Screen)                     !Open The Menu Screen
  221.   SETCURSOR                     !Turn Off Any Cursor
  222.   @Setup                     !Call Setup Procedure
  223.   LOOP                         !Loop Until User Exits
  224.     @Lookups                     !Display From Other Files
  225.     @Show                     !Display String Variables
  226.     @Compute                     !Display Computed Fields
  227.     @Conditional                 !Display Conditional Fields
  228.     @Result                     !Move Resulting Values
  229.     ALERT                     !Turn Off All Alerted Keys
  230.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  231.     ALERT(Tab_Key)                 !!Alert Tab Key
  232.     ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  233.     @Alert                     !Alert Hot Keys
  234.     ACCEPT                     !Read A Field Or Menu Choice
  235.     @CheckHot                     !On Hot Key, Call Procedure
  236.     IF KEYCODE() = Shft_Tab    |         !!If Shft_Tab Pressed
  237.     AND FIELD() ~= ?First_Field             !!And Not First Field
  238.       UPDATE(?)                     !!  Update Current Field
  239.       SELECT(?-1)                 !!  Go Back One Field
  240.     ELSIF KEYCODE() = Tab_Key             !!Elsif Tab Key Pressed
  241.       UPDATE(?)                     !!  Update Current Field
  242.     .                         !!.
  243.  
  244.     Edit_Range# = FIELD()             !Set One Field Edit Range
  245.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  246.       UPDATE                     !  Move All Fields From Screen
  247.       Edit_Range# = ?Menu_Field - 1         !  And Edit Remaining Fields
  248.       SELECT(?Menu_Field)             !  If Ok Then Start Here Next
  249.     .                         !
  250.  
  251.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  252.  
  253.       CASE Field#                 !Jump To Field Edit Routine
  254.  
  255.       @Edits                     !Edit Routines Go Here
  256.       OF ?Menu_Field                 !From The Menu Field
  257.     EXECUTE CHOICE()             !  Call The Selected Procedure
  258.       @Menu                     !
  259.   . . . .
  260. *HorzMenu***********************************************************************
  261. @ProcName    PROCEDURE                 !!New Menu Model Procedure
  262.  
  263. Screen         SCREEN      PRE(Scr),@ScreenOpt
  264.               @Paints
  265.               @Strings
  266.               @Variables
  267.               ENTRY,USE(?First_Field)
  268.               @Fields
  269.               MENU,USE(Menu_Field),REQ  !!Remove "?" From Use
  270.                 @CHOICES
  271.          .          .
  272.  
  273. Menu_Field   STRING(80)                 !!Add This Variable
  274. Esc_Ok         BYTE                 !!Add This Variable
  275.  
  276.   EJECT
  277.   CODE
  278.   OPEN(Screen)                     !Open The Menu Screen
  279.   SETCURSOR                     !Turn Off Any Cursor
  280.   Esc_Ok = True                     !!Turn On Esc & Ctrl-Esc
  281.   @Setup                     !Call Setup Procedure
  282.   LOOP                         !Loop Until User Exits
  283.     @Lookups                     !Display From Other Files
  284.     @Show                     !Display String Variables
  285.     @Compute                     !Display Computed Fields
  286.     @Conditional                 !Display Conditional Fields
  287.     @Result                     !Move Resulting Values
  288.     ALERT                     !Turn Off All Alerted Keys
  289.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  290.     IF Esc_Ok                     !!IF Esc & Ctrl-Esc On
  291.       ALERT(Reject_Key)                 !   Alert Screen Reject Key
  292.     .                         !!.
  293.     @Alert                     !Alert Hot Keys
  294.     ALIAS(Down_Key,Enter_Key)             !!Make Down Key Another Enter
  295.     ACCEPT                     !Read A Field Or Menu Choice
  296.     ALIAS(Down_Key,Down_Key)
  297.     @CheckHot                     !On Hot Key, Call Procedure
  298.  
  299.     IF KEYCODE() = Reject_Key THEN RETURN.     !!Return On Reject Key.
  300.  
  301.     Edit_Range# = FIELD()             !Set One Field Edit Range
  302.     IF KEYCODE() = Accept_Key             !!If Screen Accept
  303.       UPDATE                     !  Move All Fields From Screen
  304.       Edit_Range# = ?Menu_Field - 1         !  And Edit Remaining Fields
  305.       SELECT(?Menu_Field)             !  If Ok Then Start Here Next
  306.     .
  307.  
  308.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  309.  
  310.       CASE Field#                 !Jump To Field Edit Routine
  311.       OF ?First_Field                 !From The First Field
  312.     IF KEYCODE() = Esc_Key AND Esc_Ok     !!  If Esc Key Pressed
  313.       RETURN                 !!    Exit From Menu
  314.     .                     !!  .
  315.  
  316.       @Edits                     !Edit Routines Go Here
  317.       OF ?Menu_Field                 !From The Menu Field
  318.     EXECUTE CHOICE()             !  Call The Selected Procedure
  319.       @Menu                     !
  320.   . . . .
  321. *VertMenu***********************************************************************
  322. @ProcName    PROCEDURE                 !!New Menu Model Procedure
  323.  
  324. Screen         SCREEN      PRE(Scr),@ScreenOpt
  325.               @Paints
  326.               @Strings
  327.               @Variables
  328.               ENTRY,USE(?First_Field)
  329.               @Fields
  330.               MENU,USE(Menu_Field),REQ  !!Remove "?" From Use
  331.                 @CHOICES
  332.          .          .
  333.  
  334. Menu_Field   STRING(80)                 !!Add This Variable
  335.  
  336.   EJECT
  337.   CODE
  338.   OPEN(Screen)                     !Open The Menu Screen
  339.   SETCURSOR                     !Turn Off Any Cursor
  340.   @Setup                     !Call Setup Procedure
  341.   LOOP                         !Loop Until User Exits
  342.     @Lookups                     !Display From Other Files
  343.     @Show                     !Display String Variables
  344.     @Compute                     !Display Computed Fields
  345.     @Conditional                 !Display Conditional Fields
  346.     @Result                     !Move Resulting Values
  347.     ALERT                     !Turn Off All Alerted Keys
  348.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  349.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  350.     ALERT(Right_Key)                 !!Alert Right Key
  351.     ALERT(Left_Key)                 !!Alert Left Key
  352.     @Alert                     !Alert Hot Keys
  353.     ACCEPT                     !Read A Field Or Menu Choice
  354.     UPDATE(?)                     !Update Menu Choice For Sticky
  355.     @CheckHot                     !On Hot Key, Call Procedure
  356.  
  357.     Edit_Range# = FIELD()           !!Move     !Set One Field Edit Range
  358.     CASE KEYCODE()                 !!Check key
  359.     OF Reject_Key                 !!  If Reject Key
  360.       RETURN                     !!    Return
  361.     OF Left_Key                     !!  If Left Key
  362.       PutKbd('<0,75,0,80>')             !!    Push Keys:  Left, Down
  363.       RETURN                     !!    Return To Main Menu
  364.     OF Right_Key                 !!  If Right Key
  365.       PutKbd('<0,77,0,80>')             !!    Push Keys:  Right, Down
  366.       RETURN                     !!    Return To Main Menu
  367.     OF Accept_Key               !!Change     !!  If Accept Key
  368.       UPDATE                   !!Move     !     Move All Fields From Scr
  369.       Edit_Range# = ?Menu_Field - 1    !!Move     !     Edit Remaining Fields
  370.       SELECT(?Menu_Field)           !!Move     !     Start Here Next
  371.     .
  372.  
  373.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  374.  
  375.       CASE Field#                 !Jump To Field Edit Routine
  376.       OF ?First_Field                 !From The First Field
  377.     IF KEYCODE() = Esc_Key THEN RETURN.     !  Return On Esc Key.
  378.  
  379.       @Edits                     !Edit Routines Go Here
  380.       OF ?Menu_Field                 !From The Menu Field
  381.     EXECUTE CHOICE()             !  Call The Selected Procedure
  382.       @Menu                     !
  383.   . . . .
  384. *Table**************************************************************************
  385. @ProcName    PROCEDURE
  386.  
  387. Screen         SCREEN      PRE(Scr),@ScreenOpt
  388.               @Paints
  389.               @Strings
  390.               @Variables
  391.               ENTRY,USE(?First_Field)
  392.               @Fields
  393.               @PrePoint
  394.               REPEAT(@Count),EVERY(@PRows),INDEX(Ndx)
  395.           @PLoc        POINT(@PRows,@Cols),USE(?Point),ESC(?-1)
  396.                 @ScrollVariables
  397.          .          .
  398.  
  399. Ndx         BYTE                 !Repeat Index For Point Field
  400. Row         BYTE                 !Actual Row Of Scroll Area
  401. Col         BYTE                 !Actual Column Of Scroll Area
  402. Max         LONG                 !Lesser Of Count And Records
  403. Count         BYTE(@Count)             !Number Of Items To Scroll
  404. Rows         BYTE(@Rows)             !Number Of Rows To Scroll
  405. Cols         BYTE(@Cols)             !Number Of Columns To Scroll
  406. Add_Ok         BYTE                 !!Flag For Adds
  407. Chg_Ok         BYTE                 !!Flag For Changes
  408. Del_Ok         BYTE                 !!Flag For Deletes
  409.  
  410. @SAVETOTALS
  411.  
  412.   EJECT
  413.   CODE
  414.   Relocate_# = False
  415.   Action# = Action                 !Save Action
  416.   OPEN(Screen)                     !Open The Screen
  417.   SetCursor                     !Turn Off Any Cursor
  418.   Add_Ok=1; Chg_Ok=1; Del_Ok=1             !!Set Flags
  419.   @Setup                     !Call Setup Procedure
  420.   Ndx = 1                     !Put Selector Bar On Top Item
  421.   Row = ROW(?Point)                 !Remember Top Row And
  422.   Col = COL(?Point)                 !  Left Column Of Scroll Area
  423.   @TOTALCALC                     !BUILD TABLE TOTAL FIELDS
  424.   IF Action = eView                 !If This Is A Lookup Request
  425.     SET(@KeyName,@KeyName); ChkErr         !  Find It In The File
  426.     NEXT(@FileName) !!No ChkErr             !    And Read It
  427.     Pointer# = POINTER(@FileName)         !  Save Pointer To Current
  428.     SKIP(@FileName,-1)                 !  Make It The Top Record
  429.     DO Show_Table                 !  Fill Scroll Area
  430.     GET(@FileName,Pointer#) !!No ChkErr         !  And Refresh Current Record
  431.   ELSE                         !Otherwise
  432.     SET(@KeyName); ChkErr             !  Set To First Record In File
  433.     DO Show_Table                 !  Fill Scroll Area
  434.   .
  435.   Records# = True                 !Initialize Records Flag
  436.   LOOP                         !Loop Until User Exits
  437.     Mem:Message = CENTER(Mem:Message)         !!Center Message
  438.     Max = RECORDS(@KeyName)             !Set Lesser Of File Record
  439.     IF Max > Count THEN Max = Count.         !Count And Scroll Item Count
  440.     Action = Action#                 !Restore Action
  441.     Pointer# = 0                 !Clear Add Pointer
  442.     @TOTSHOW                     !DISPLAY TOTAL AMOUNT ON SCREEN
  443.     @Lookups                     !Display From Other Files
  444.     @Show                     !Display String Variables
  445.     @Compute                     !Display Computed Fields
  446.     @Conditional                 !Display Conditional Fields
  447.     @Result                     !Move Resulting Values
  448.     IF ~RECORDS(@KeyName)             !If There Are No Records
  449.       IF Add_Ok                     !! If Ok To Add Records
  450.     CLEAR(@Pre:Record)             !    Clear Record Area
  451.     Action = eAdd                 !    Set Action To Add
  452.     @AutoNumKey                 !    Auto Increment Key Field
  453.     @UPDATE                     !    Call Form For First Record
  454.     IF ~RECORDS(@KeyName) THEN BREAK.     !    If Add Aborted Then Exit
  455.       DO SHOW_RECORD                 !    PERFORM ALL CALCULATIONS
  456.       @TOTPLUS                     !    UPDATE TOTAL FIELDS
  457.     SET(@KeyName); ChkErr             !    Set To New Record
  458.     DO Show_Table                 !    Fill Scroll Area
  459.     Ndx = 1                     !    Put Selector On Top Item
  460.     Max = 1                     !    Maximum Displayed Is 1
  461.       ELSE                     !! Else (No Adds Allowed)
  462.     NoRecs                     !!   Tell User
  463.     BREAK                     !!   Break From Screen Loop
  464.     . .                         !. .
  465.     ALERT                     !Reset Alerted Keys
  466.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  467.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  468.     ALERT(Tab_Key)                 !!Alert Tab Key
  469.     ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  470.     @Alert                     !Alert Hot Key
  471.     ACCEPT                     !Read A Field
  472.     @TableHot                     !On Hot Key, Call Procedure
  473.     IF KEYCODE() = Reject_Key             !!If Reject Key Pressed
  474.       BREAK                     !!  Break
  475.     ELSIF KEYCODE() = Shft_Tab     |         !!Else If Shft-Tab Pressed
  476.     AND FIELD() ~= ?First_Field             !!And Not First Field
  477.       UPDATE(?)                     !!  Update Current Field
  478.       SELECT(?-1)                 !!  Go To Previous Field
  479.     ELSIF KEYCODE() = Tab_Key             !!Else If Tab Pressed
  480.       UPDATE(?)                     !!  Update Current Field
  481.     .                         !!.
  482.  
  483.     Edit_Range# = FIELD()             !Set One Field Edit Range
  484.     IF KEYCODE() = Accept_Key AND  |         !On Screen Accept Key
  485.        Edit_Range# <> ?Point             ! And Not On The Point Field
  486.       UPDATE                     !  Move All Fields From Screen
  487.       Edit_Range# = ?Point - 1             !  And Edit Remaining Fields
  488.       SELECT(?Point)                 !  If Ok Then Start Here Next
  489.     .                         !
  490.  
  491.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  492.  
  493.       CASE Field#                 !Jump To Field Edit Routine
  494.       OF ?First_Field                 !From The First Field
  495.     IF KEYCODE() = Esc_Key    |         !  Return On Esc Key
  496.     OR Records# = False             !  Or No Records
  497.        RETURN
  498.     .
  499.       @Edits                     !Edit Routines Go Here
  500.     Records# = True                 !  Assume Records Are Here
  501.       @InitLocate                 !Show Cursor For Locator
  502.       OF ?Point                     !From The Point Field
  503.     @Locate
  504.     CASE KEYCODE()                 !  Process The Keystroke
  505.     OF Ins_Key                 !Insert Key
  506.       IF Add_Ok                 !! If Ok To Add Records
  507.         CLEAR(@Pre:Record)             !    Clear Record Area
  508.         Action = eAdd             !    Set Action To Add
  509.         @AutoNumKey                 !    Auto Increment Key Field
  510.         @TOTCHECK                 !  SAVE TOTAL FIELD AMOUNT
  511.         @Update                 !    Call Form For New Record
  512.         @AUTONUMESC                 !  RECORD NOT ADDED
  513.         IF ~Action                 !    If A New Record Was Added
  514.           Pointer# = POINTER(@FileName)     !    Remember Which Record
  515.           SET(@KeyName,@KeyName); ChkErr     !    Set To New Record And
  516.           SKIP(@FileName,-1)         !    Make It The Top Item
  517.           DO Show_Table             !    Display That Page
  518.         .                     !    .
  519.       ELSE                     !! Else (No Adds Allowed)
  520.         Mem:Message='You may not add records!'!!  Inform User
  521.         BEEP                 !!   Beep
  522.       .                     !! .
  523.     OF Enter_Key                 !Enter Key Or
  524.     OROF Accept_Key                 !Ctrl Enter Key
  525.       DO Get_Record                 !  Read The Selected Record
  526.       IF Action = eView         |         !  If This Is A Lookup Request
  527.       AND KEYCODE() = Enter_Key         !
  528.         Action = eDone             !    Set Action To Complete
  529.         RETURN                 !    And Return To Caller
  530.       .                     !
  531.       IF Chg_Ok                 !! If Ok To Change Records
  532.         Action = eChange             !    Set Action To Change
  533.       @TOTCHECK                 !  SAVE TOTAL FIELD AMOUNT
  534.         @Update                 !    Call Form To Change Record
  535.         IF ~Action                 !    If The Record Was Changed
  536.           Pointer# = POINTER(@FileName)     !    Remember Which Record
  537.           SET(@KeyName,@KeyName); ChkErr     !    Set To Changed Record
  538.           SKIP(@FileName,-1)         !    Make It The Top Item
  539.           DO Show_Table             !    And Display That Page
  540.         ELSE                 !    Otherwise
  541.           SKIP(@FileName,Max-Ndx); ChkErr     !    Skip Back To Same Page
  542.         .                     !    .
  543.       ELSE                     !! Else (Changes Not Allowed)
  544.         Action = eView             !!   Set Action To View
  545.         @Update                 !!   Call Form To View Record
  546.         SKIP(@FileName,Max-Ndx); ChkErr     !!   Skip Back To Same Page
  547.       .                     !!.
  548.     OF Del_Key                 !Delete Key
  549.       IF Del_Ok                 !! If Ok To Delete Records
  550.         DO Get_Record             !    Read The Selected Record
  551.         Action = eDelete             !    Set Action To Delete
  552.       @TOTSAVE                 !  SAVE TOTAL FIELD AMOUNT
  553.         @Update                 !    Call Form To Delete Record
  554.         IF ~Action                 !    If Record Was Deleted
  555.         @TOTMINUS                 !    SUBTRACT FROM TOTAL FLDS
  556.           SKIP(@FileName,-Ndx)         !    Set Next Record On Top
  557.           DO Show_Table             !    And Display That Page
  558.         ELSE                 !    Otherwise
  559.           SKIP(@FileName,(Max-Ndx))         !    Skip Back To Same Page
  560.         .                     !    .
  561.       ELSE                     !! Else (Deletes Not Allowed)
  562.         Mem:Message='You may not delete records!'!! Inform User
  563.         BEEP                 !!    Beep
  564.       .                     !! .
  565.     OF Down_Key                 !Down Arrow Key
  566.       IF NOT EOF(@FileName)             !  If There Are More Records
  567.         SCROLL(Row,Col,Rows,Cols,ROWS(?Point)) !  Scroll The Screen Up
  568.         NEXT(@FileName); ChkErr         !    Read The Bottom Record
  569.         DO Show_Record             !    And Display It
  570.       .
  571.     OF PgDn_Key                 !Page Down Key
  572.       IF EOF(@FileName)             !  On The Last Page
  573.         Ndx = Max                 !    Point To Bottom Item
  574.       ELSE                     !  Otherwise
  575.         DO Show_Table             !    Display Next Page
  576.       .
  577.     OF Ctrl_PgDn                 !Ctrl-Page Down Key
  578.       Ndx = Max                 !  Point To Bottom Item
  579.       IF NOT EOF(@FileName)             !  On The Last Page
  580.         SET(@KeyName); ChkErr         !    Set To Bottom Record Minus
  581.         SKIP(@FileName,-Count)         !    One Page Of Records
  582.         DO Show_Table             !    Display The Last Page
  583.       .
  584.     OF Up_Key                 !Up Arrow Key
  585.       SKIP(@FileName,-(Count-1))         !  Set To Top Record Minus 1
  586.       IF NOT BOF(@FileName)             !  If There Is A Prior Record
  587.         PREVIOUS(@FileName)             !    Read The Top Record
  588.         IF NOT ERROR()             !    If Read A Record
  589.           SCROLL(Row,Col,Rows,Cols,-(ROWS(?Point)))! Scroll The Screen Down
  590.           DO Show_Record             !     And Display It
  591.         ELSIF ERRORCODE() = 33         !    Elsif Record Not Available
  592.           NEXT(@FileName); ChkErr         !     Retrieve First One
  593.       . .
  594.       SKIP(@FileName,Count-1)         !  Set Record For Next Page
  595.  
  596.     OF PgUp_Key                 !Page Up Key
  597.       SKIP(@FileName,-(Count-1))         !  Set To Top Record Minus One
  598.       IF BOF(@FileName)             !  If There Is No Prior Record
  599.         Ndx = 1                 !    Then Point To Top Item
  600.         SKIP(@FileName,Count-1)         !    Set Record For This Page
  601.       ELSE                     !  Otherwise
  602.         SKIP(@FileName,-(Count+1))         !    Set Record For Prior Page
  603.         DO Show_Table             !    And Display The Page
  604.       .
  605.     OF Ctrl_PgUp                 !Ctrl-Page Up Key
  606.       SET(@KeyName); ChkErr             !  Set To First Record
  607.       Ndx = 1                 !  Point To Top Item
  608.       DO Show_Table                 !  And Display The Page
  609.   . . . .                     !.
  610.   RETURN                     !Return To Caller
  611.  
  612. Show_Table ROUTINE                 !Display A Page Of Records
  613.   SKIP(@FileName,Count-1)             !  Set To The Bottom Record
  614.   IF EOF(@FileName)                 !  For A Partial Page
  615.     SET(@KeyName); ChkErr             !    Set To The Last Record
  616.     SKIP(@FileName,-Count)             !    And Back Up One Page
  617.   ELSE                         !  Otherwise
  618.     SKIP(@FileName,-(Count-1))             !    Set Record For This Page
  619.   .
  620.   Ndx# = Ndx                     !  Save Repeat Index
  621.   LOOP Ndx = 1 TO Count                 !  Loop Thru The Scroll Area
  622.     IF EOF(@FileName) THEN BREAK.         !    Break On End Of File
  623.     IF Relocate_#             |
  624.     AND (INRANGE(KEYBOARD(),32,254)  |
  625.     OR KEYBOARD()=BS_Key)
  626.       EXIT
  627.     .
  628.     NEXT(@FileName); ChkErr             !    Read The Next Record
  629.     DO Show_Record                 !    And Display It
  630.     IF POINTER(@FileName) = Pointer#             !Point To Correct Record
  631.      Ndx# = Ndx
  632.       @DOTOTALS                     !  CALCULATE TOTAL FIELDS
  633.   ..
  634.   Ndx = Ndx#                     !  Restore Repeat Index
  635.   CLEAR(@Pre:Record)                 !  Clear Record Area
  636.   IF RECORDS(@KeyName) < Count             !  If Records Do Not Fill
  637.     Ndx#= RECORDS(@KeyName) * @PRows         !     Get Number Times Size
  638.     BLANK(Row + Ndx#,Col,Rows-Ndx#,Cols)     !     Blank Remaining Area
  639.   .
  640.   Relocate_# = False
  641.  
  642. Show_Record ROUTINE                 !Display A Record
  643.   @LookupScroll                     !  Display From Other Files
  644.   @ShowScroll                     !  Display String Variables
  645.   @ComputeScroll                 !  Display Computed Fields
  646.   @ConditionalScrl                 !  Display Conditional Fields
  647.   @ResultScroll                     !  Assign Result Fields
  648.  
  649. Get_Record ROUTINE                 !Read Selected Record
  650.   SKIP(@FileName,-(Max-Ndx+1))             !  Set To Selected Record
  651.   NEXT(@FileName) !!No ChkErr             !    And Read It
  652.  
  653. Find_Record ROUTINE                 !Locate Requested Record
  654.   SET(@KeyName,@KeyName); ChkErr         !  Set To Requested Record
  655.   IF EOF(@FileName)                 !  If Beyond End Of File
  656.     PREVIOUS(@FileName); ChkErr             !    Get The Last Record
  657.   ELSE                         !  Else
  658.     NEXT(@FileName); ChkErr             !    Read This Record
  659.   .
  660.   Pointer# = POINTER(@FileName)             !  Save Its Record Pointer
  661.   SKIP(@FileName,-1)                 !  Make It The Top Record
  662.   DO Show_Table                     !  And Fill The Scroll Area
  663.  
  664. Same_Page ROUTINE                 !Set To Same Page Routine
  665.   Pointer# = POINTER(@FileName)             !  Save Its Record Pointer
  666.   GET(@FileName,Pointer#); ChkErr         !  Get The Record
  667.   SET(@KeyName,@KeyName); ChkErr         !  Set To The Same Record
  668.   SKIP(@FileName,-1)                 !  Skip To Top Of Same Page
  669.  
  670. @COMPUTETOTS                     !CALCULATE TOTAL FIELDS
  671. *SelTable***********************************************************************
  672. @ProcName    PROCEDURE
  673.  
  674. Screen         SCREEN      PRE(Scr),@ScreenOpt
  675.               @Paints
  676.               @Strings
  677.               @Variables
  678.               ENTRY,USE(?First_Field)
  679.               @Fields
  680.               @PrePoint
  681.               REPEAT(@Count),EVERY(@PRows),INDEX(Ndx)
  682.           @PLoc        POINT(@PRows,@Cols),USE(?Point),ESC(?-1)
  683.                 @ScrollVariables
  684.          .          .
  685.  
  686. Ptr         LONG                 !Entry Pointer For Key Table
  687. Ndx         BYTE                 !Repeat Index For Point Area
  688. Row         BYTE                 !Actual Row Of Scroll Area
  689. Col         BYTE                 !Actual Column Of Scroll Area
  690. Count         BYTE(@Count)             !Number Of Items To Scroll
  691. Rows         BYTE(@Rows)             !Number Of Rows To Scroll
  692. Cols         BYTE(@Cols)             !Number Of Columns To Scroll
  693. Add_Ok         BYTE                 !!Flag For Adds
  694. Chg_Ok         BYTE                 !!Flag For Changes
  695. Del_Ok         BYTE                 !!Flag For Deletes
  696.  
  697. Table         TABLE                 !Table Of Record Keys
  698. TblPtr           LONG                 !  Pointer To Data Record
  699. Key           GROUP,PRE(Tbl)             !  Record Key Fields
  700.          @Components
  701.          . .
  702. @SaveItems
  703. @SAVETOTALS
  704.  
  705.   EJECT
  706.   CODE
  707.   Relocate_# = False
  708.   Action# = Action                 !Save Action
  709.   OPEN(Screen)                     !Open The Screen
  710.   SETCURSOR                     !Turn Off Any Cursor
  711.   Add_Ok=1; Chg_Ok=1; Del_Ok=1             !!Init Flags
  712.   @Setup                     !Call Setup Procedure
  713.   @InitSelects                     !Save Selector Fields
  714.   @TOTCLEAR                     !ZERO TOTAL FIELDS
  715.   Ptr = 1                     !Start At Table Entry
  716.   Ndx = 1                     !Put Selector Bar On Top Item
  717.   Row = ROW(?Point)                 !Remember Top Row And
  718.   Col = COL(?Point)                 !Left Column Of Scroll Area
  719.   Records# = True                 !Initialize Records Flag
  720.   LOOP                         !Loop Until User Exits
  721.     Mem:Message = CENTER(Mem:Message)         !!Center Message
  722.     Action = Action#                 !Restore Action
  723.     @RestSelects                 !Restore Selector Fields
  724.     @TOTSHOW                     !DISPLAY TOTAL AMOUNTS ON SCRN
  725.     @Lookups                     !Display From Other Files
  726.     @Show                     !Display String Variables
  727.     @Compute                     !Display Computed Fields
  728.     @Conditional                 !Display Conditional Fields
  729.     @Result                     !Move Resulting Values
  730.     ALERT                     !Reset Alerted Keys
  731.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  732.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  733.     ALERT(Tab_Key)                 !!Alert Tab Key
  734.     ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  735.     @Alert                     !Alert Hot Key
  736.     ACCEPT                     !Read A Field
  737.     Mem:Message = ''                 !Clear Message Area
  738.     @TableHot                     !On Hot Key, Call Procedure
  739.     IF KEYCODE() = REJECT_KEY             !!If Reject Key Pressed
  740.       BREAK                     !!  Return
  741.     ELSIF KEYCODE() = Shft_Tab    |         !!If Shft_Tab Pressed
  742.     AND FIELD() ~= ?First_Field             !!And Not First Field
  743.       UPDATE(?)                     !!  Update Current Field
  744.       SELECT(?-1)                 !!  Go Back One Field
  745.     ELSIF KEYCODE() = Tab_Key             !!Elsif Tab Key Pressed
  746.       UPDATE(?)                     !!  Update Current Field
  747.     .                         !!.
  748.  
  749.     Edit_Range# = FIELD()             !Set One Field Edit Range
  750.     IF KEYCODE() = Accept_Key  |         !On Screen Accept Key
  751.     AND Edit_Range# <> ?Point             ! And Not On The Point Field
  752.       UPDATE                     !  Move All Fields From Screen
  753.       Edit_Range# = ?Point - 1             !  And Edit Remaining Fields
  754.       SELECT(?Point)                 !  If Ok Then Start Here Next
  755.     .                         !
  756.  
  757.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  758.  
  759.       CASE Field#                 !Jump To Field Edit Routine
  760.  
  761.       OF ?First_Field                 !From The First Field
  762.     IF KEYCODE() = Esc_Key    |         !  Return On Esc Key
  763.     OR Records# = False             !  Or No Records
  764.       FREE(Table)                 !  Free The Table Of Points
  765.       RETURN                 !  Return To Caller
  766.     .
  767.     @Edits                     !Edit Routines Go Here
  768.     Records# = True                 !  Assume There Are Records
  769.     @InitLocate
  770.       OF ?Point                     !Process The Point Field
  771.     IF ~RECORDS(Table)             !If There Are No Records
  772.       IF Add_Ok                 !! If Ok To Add Records
  773.         CLEAR(@Pre:Record)             !    Clear Record Area
  774.         UPDATE                 !    Update All Fields
  775.         Action = eAdd             !    Set Action To Add
  776.         @AutoNumKey                 !    Auto Increment Key Field
  777.         @TOTCHECK                 !  SAVE TOTAL FIELD AMOUNT
  778.         @Update                 !    Call Form For First Record
  779.         IF ~Action                 !    If Record Was Added
  780.           DO Add_Table             !    Then Add New Table Entry
  781.           DO Sort_Table             !    Sort The Table
  782.           DO Show_Table             !    And Display First Page
  783.         .                     !    .
  784.         IF ~RECORDS(Table)             !    If Add Aborted Try Again
  785.         Records# = False         !    Indicate No Records
  786.         SELECT(?-1)             !    Select Previous Field
  787.         BREAK                 !    End The Edits
  788.         .                     !    .
  789.         CYCLE                 !    Continue The Edit
  790.       ELSE                     !! Else (Adds Not Allowed)
  791.         NoRecs                 !!   Inform User
  792.         SELECT(?-1)                 !!   Select Previous Field
  793.         BREAK                 !!   End The Edits
  794.     . .                     !. .
  795.     @Locate
  796.     CASE KEYCODE()                 !Process The Keystroke
  797.  
  798.     OF Enter_Key                 !Enter Key Or
  799.     OROF Accept_Key                 !Ctrl-Enter Key
  800.       DO Get_Record                 !  Read The Selected Record
  801.       IF ERROR()                 !  If Record Has Been Deleted
  802.         Mem:Message = ERROR()         !    Tell User What Happened
  803.         SELECT(?)                 !    Stay In The Point Field
  804.         DO Build_Table             !    Rebuild Table
  805.         DO Sort_Table             !    Sort It
  806.         DO Show_Table             !    Show It
  807.         BREAK                 !    And Get Another Key
  808.       .
  809.       IF Action = eView         |         !  If This Is A Lookup Request
  810.       AND KEYCODE() = Enter_Key
  811.         Action = eDone             !    Set Action To Complete
  812.         FREE(Table)                 !    Free The Table Of Points
  813.         RETURN                 !    Return To Caller
  814.       .
  815.       IF Chg_Ok                 !! If Ok To Add Records
  816.         Action = eChange             !    Set Action To Change
  817.       @TOTSAVE                 !  SAVE TOTAL FIELD AMOUNT
  818.         @Update                 !    Call Form To Change Record
  819.         IF ~Action                 !    If The Record Was Changed
  820.         @TOTMINUS                 !    SUBTRACT OLD TOTAL AMOUNT
  821.           DELETE(Table); ChkErr         !    Delete Old Table Entry
  822.           DO Add_Table             !    Add New Table Entry
  823.           DO Sort_Table             !    Sort The Table
  824.           DO Show_Table             !    And Display That Page
  825.         .                     !    .
  826.       ELSE                     !! Else (Changes Not Allowed)
  827.         Action = eView             !!   Set Action To View
  828.         @Update                 !!   Call Proc To View Record
  829.       .                     !!.
  830.     OF Ins_Key                 !Ins Key
  831.       IF Add_Ok                 !! If Ok To Add Records
  832.         CLEAR(@Pre:Record)             !    Clear Record Area
  833.         Update                 !    Update All Fields
  834.         Action = eAdd             !    Set Action To Add
  835.         @AutoNumKey                 !    Auto Increment Key Field
  836.         @Update                 !    Call Form For New Record
  837.         IF ~Action                 !    If Record Was Added
  838.           DO Add_Table             !    Add New Table Entry
  839.           DO Sort_Table             !    Sort The Table
  840.           DO Show_Table             !    And Display That Page
  841.         .                     !    .
  842.       ELSE                     !! Else (Adds Not Allowed)
  843.         MEM:MESSAGE='You may not add records!'!!  Set Error Message
  844.         BEEP                 !!   Beep
  845.       .                     !!.
  846.     OF Del_Key                 !Del Key
  847.       IF Del_Ok                 !! If Ok To Delete Records
  848.         DO Get_Record             !    Read The Selected Record
  849.         IF ERROR()                 !    If Record Has Been Deleted
  850.           Mem:Message = ERROR()         !    Tell User What Happened
  851.           SELECT(?)                 !    Stay On The Point Field
  852.           DO Build_Table             !    Rebuild Table
  853.           DO Sort_Table             !    Sort It
  854.           DO Show_Table             !    Show It
  855.           Break                 !    And Get Another Key
  856.         .                     !    .
  857.       @TOTSAVE                 !  SAVE TOTAL FIELD AMOUNT
  858.         Action = eDelete             !    Set Action To Delete
  859.         @Update                 !    Call Form To Delete Record
  860.         IF ~Action                 !    If Record Was Deleted
  861.         @TOTMINUS                 !    SUBTRACT FROM TOTAL FLDS
  862.           DELETE(Table); ChkErr         !    Delete Table Entry
  863.           DO Show_Table             !    And Display That Page
  864.         .                     !    .
  865.       ELSE                     !! Else (Deletes Not Allowed)
  866.         Mem:Message='You may not delete records!'!! Inform User
  867.         BREAK                     !! Break From Edits
  868.       .
  869.     OF Down_Key                 !Down Arrow Key
  870.       IF Ptr <= RECORDS(Table)-Count     !  If There Are More Entries
  871.         SCROLL(Row,Col,Rows,Cols,ROWS(?Point)) !  Scroll The Screen Up
  872.         Ptr += 1                 !    Set To The Next Entry
  873.         DO Show_Record             !    And Display The Record
  874.       .
  875.     OF PgDn_Key                 !Page Down Key
  876.       IF Ptr >= RECORDS(Table)-Count+1     !  On The Last Page
  877.         Ndx = Count                 !    Point To Bottom Item
  878.       .
  879.       Ptr += Count                 !  Otherwise
  880.       TblPtr = -1                 !  Not Set To A Record
  881.       DO Show_Table                 !    Display The Next Page
  882.  
  883.     OF Ctrl_PgDn                 !Ctrl-Page Down Key
  884.       Ptr = RECORDS(Table) - Count + 1     !  Set To Last Page
  885.       Ndx = Count                 !  Point To Bottom Item
  886.       TblPtr = -1                 !  Not Set To A Record
  887.       DO Show_Table                 !  Display The Last Page
  888.  
  889.     OF Up_Key                 !Up Arrow Key
  890.       IF Ptr > 1                 !  If There Is A Prior Record
  891.         Ptr -= 1                 !    Set To Prior Record
  892.         SCROLL(Row,Col,Rows,Cols,-(ROWS(?Point)))! Scroll The Screen Down
  893.         DO Show_Record             !    Display The Record
  894.       .
  895.     OF PgUp_Key                 !Page Up Key
  896.       IF Ptr = 1 THEN Ndx = 1.         !  On First Page Point To Top
  897.       Ptr -= Rows                 !  Otherwise Back Up 1 Page
  898.       TblPtr = -1                 !  Not Set To A Record
  899.       DO Show_Table                 !  And Display It
  900.  
  901.     OF Ctrl_PgUp                 !Ctrl-Page Up
  902.       Ptr = 1                 !  Point To First Record
  903.       Ndx = 1                 !  Point To Top Item
  904.       TblPtr = -1                 !  Not Set To A Record
  905.       DO Show_Table                 !  And Display The First Page
  906.   . . . .                     !
  907.  
  908.   FREE(Table)                     !Free Memory Table
  909.   RETURN                     !And Return To Caller
  910.  
  911. Build_Table ROUTINE                 !Build Memory Table
  912.   Free(Table)         !!Redundant With Readtable     !Empty The Table
  913.   Clear(@Pre:Record) !!Redundant With Readtable !Make Sure Record Cleared
  914.   @TOTCLEAR                     !ZERO TOTAL FIELDS
  915.   @Restselects         !!Redundant With Readtable     !Restore Selector Criteria
  916. ! Update         !!Causes Partial Tables     !Update All Fields
  917. ! #Result         !!Causes Partial Tables     !Do Computed Fields Results
  918.   @ReadTable                     !Do Selector Or Filter
  919.   TblPtr = -1                     !Initialize To No Record
  920.   DO Show_Table                     !Display A Page Of Records
  921.  
  922. Add_Table ROUTINE                 !Add Entry To Memory Table
  923.   @CheckAdd                     !
  924.   IF ~(@Filter) THEN EXIT.             !  Exit If Filtered Out
  925.   @SetComponents                 !  Move Key Components
  926.   TblPtr = POINTER(@FileName)             !  Save Data Record Pointer
  927.   ADD(Table)                     !  Add New Table Entry
  928.   IF ERROR()                     !  If Out Of Memory
  929.     Mem:Message = ERROR()             !    Inform User
  930.     BEEP                     !    Sound Alarm
  931.   .
  932.   @TOTALCALCSEL                     !CALCULATE TOTAL FIELDS
  933.  
  934. Sort_Table ROUTINE                 !Sort Table Entries
  935.   TblPtr# = TblPtr                 !  Save Data Record Pointer
  936.   @SortTable                     !  Sort The Table
  937.   LOOP Ptr = 1 TO RECORDS(Table)         !  Look Up The Saved Pointer
  938.     GET(Table,Ptr); ChkErr             !    So We Will Still Point
  939.     IF TblPtr = TblPtr# THEN EXIT.         !    At The Same Record
  940.   .
  941.  
  942. Show_Table ROUTINE                 !Display A Page Of Records
  943.   IF Ptr > RECORDS(Table)-Count+1         !  For A Partial Page
  944.     Ptr = RECORDS(Table)-Count+1         !    Set To The Last Record
  945.   .
  946.   IF Ptr < 1 THEN Ptr = 1.             !    And Back Up One Page
  947.   TblPtr# = TblPtr                 !  Save Data Record Pointer
  948.   Ndx# = Ndx                     !  Save Repeat Index
  949.   LOOP Ndx = 1 TO Count                 !  Loop Thru The Scroll Area
  950.     IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  951.     DO Show_Record                 !    Display A Record
  952.     IF TblPtr# = TblPtr THEN Ndx# = Ndx.     !    Point To Correct Record
  953.   .                         !
  954.   Ndx = Ndx#                     !  Restore Repeat Index
  955.   IF Ndx > RECORDS(Table) THEN Ndx = RECORDS(Table).!Showing The Last
  956.   CLEAR(@Pre:Record)                 !  Clear Record Area
  957.   IF RECORDS(Table) < Count             !  If Records Do Not Fill
  958.      Ndx#= RECORDS(Table) * @PRows         !     Get Number Times Size
  959.      BLANK(Row+Ndx#,Col,Rows-Ndx#,Cols)         !     Blank Remaining Area
  960.   .
  961.   Relocate_# = False
  962.  
  963. Show_Record ROUTINE                 !Display A Record
  964.   TblPtr = 0                     !  Start With No Record
  965.   GET(Table,Ptr+Ndx-1)                 !  Get The Table Entry
  966.   IF ~ERROR()                     !  If There Is One
  967.     GET(@FileName,TblPtr)             !    Read A Data Record
  968.     IF ~ERROR()
  969.       @RestSelects                 !    Restore Selector Fields
  970.     ! #LookupScroll                 !    Display From Other Files
  971.     ! #ShowScroll                 !    Display String Variables
  972.     ! #ComputeScroll                 !    Display Computed Fields
  973.     ! #ConditionalScrl                 !    Display Conditional Fields
  974.     ! #ResultScroll                 !    Assign Result Fields
  975.       DO SHOW_LINE                 !    DISPLAY SCROLLING LINE
  976.   . .
  977.  
  978. SHOW_LINE    ROUTINE                 !DISPLAY SCROLLING LINE
  979.   @LOOKUPSCROLL                     !    DISPLAY FROM OTHER FILES
  980.   @SHOWSCROLL                     !    DISPLAY STRING VARIABLES
  981.   @COMPUTESCROLL                 !    DISPLAY COMPUTED FIELDS
  982.   @CONDITIONALSCRL                 !    DISPLAY CONDITIONAL FIELDS
  983.   @RESULTSCROLL                     !    ASSIGN RESULT FIELDS
  984.  
  985. Get_Record ROUTINE                 !Read Selected Record
  986.   GET(Table,Ptr+Ndx-1); ChkErr             !  Get The Table Entry
  987.   GET(@FileName,TblPtr); ChkErr             !  Read The Data Record
  988.  
  989. Find_Record ROUTINE                 !Locate Requested Record
  990.   @SetComponents                 !  Move Them To The Table
  991.   IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  992.   GET(Table,Key)                 !  Get The Table Entry
  993.   IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  994.   Ptr = POINTER(Table)                 !  Set Record Pointer
  995.   IF ~Ptr THEN Ptr = RECORDS(Table).         !  Set To Last If No Pointer
  996.   GET(Table,Ptr); ChkErr             !  And Read The Data Record
  997.   IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  998.   DO Show_Table                     !  Display That Page
  999.  
  1000. Same_Page ROUTINE                 !Set To Same Page Routine
  1001.   DO Sort_Table                     !  Sort The Table
  1002.  
  1003. @COMPUTETOTS                     !CALCULATE TOTAL FIELDS
  1004. *MarkSelTable*******************************************************************
  1005. @ProcName    PROCEDURE
  1006.  
  1007. Screen         SCREEN      PRE(Scr),@ScreenOpt
  1008.               @Paints
  1009.               @Strings
  1010.               @Variables
  1011.               ENTRY,USE(?First_Field)
  1012.               @Fields
  1013.               @PrePoint
  1014.               REPEAT(@Count),EVERY(@PRows),INDEX(Ndx)
  1015.           @PLoc        POINT(@PRows,@Cols),USE(?Point),ESC(?-1)
  1016.                 @ScrollVariables
  1017.          .          .
  1018.  
  1019. Space_Key    EQUATE(32)
  1020.  
  1021. Ptr         LONG                 !Entry Pointer For Key Table
  1022. Ndx         BYTE                 !Repeat Index For Point Area
  1023. Row         BYTE                 !Actual Row Of Scroll Area
  1024. Col         BYTE                 !Actual Column Of Scroll Area
  1025. Count         BYTE(@Count)             !Number Of Items To Scroll
  1026. Rows         BYTE(@Rows)             !Number Of Rows To Scroll
  1027. Cols         BYTE(@Cols)             !Number Of Columns To Scroll
  1028. Add_Ok         BYTE                 !!Flag For Adds
  1029. Chg_Ok         BYTE                 !!Flag For Changes
  1030. Del_Ok         BYTE                 !!Flag For Deletes
  1031.  
  1032. Table         TABLE,PRE(Tbl)             !Table Of Record Keys
  1033. TblPtr           LONG                 !  Pointer To Data Record
  1034. Mark           STRING(1)
  1035. Key           GROUP                 !  Record Key Fields
  1036.          @Components
  1037.          . .
  1038. @SaveItems
  1039. @SAVETOTALS
  1040.  
  1041.   EJECT
  1042.   CODE
  1043.   Relocate_# = False
  1044.   Action# = Action                 !Save Action
  1045.   OPEN(Screen)                     !Open The Screen
  1046.   SETCURSOR                     !Turn Off Any Cursor
  1047.   Add_Ok=1; Chg_Ok=1; Del_Ok=1             !!Init Flags
  1048.   @Setup                     !Call Setup Procedure
  1049.   @InitSelects                     !Save Selector Fields
  1050.   @TOTCLEAR                     !ZERO TOTAL FIELDS
  1051.   Ptr = 1                     !Start At Table Entry
  1052.   Ndx = 1                     !Put Selector Bar On Top Item
  1053.   Row = ROW(?Point)                 !Remember Top Row And
  1054.   Col = COL(?Point)                 !Left Column Of Scroll Area
  1055.   Records# = True                 !Initialize Records Flag
  1056.   LOOP                         !Loop Until User Exits
  1057.     Mem:Message = CENTER(Mem:Message)         !!Center Message
  1058.     Max = RECORDS(Table)             !!Set Lesser Of File Record
  1059.     IF Max > Count THEN Max = Count.         !!Count And Scroll Item Count
  1060.     Action = Action#                 !Restore Action
  1061.     @RestSelects                 !Restore Selector Fields
  1062.     @TOTSHOW                     !DISPLAY TOTAL AMOUNTS ON SCRN
  1063.     @Lookups                     !Display From Other Files
  1064.     @Show                     !Display String Variables
  1065.     @Compute                     !Display Computed Fields
  1066.     @Conditional                 !Display Conditional Fields
  1067.     @Result                     !Move Resulting Values
  1068.     ALERT                     !Reset Alerted Keys
  1069.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  1070.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  1071.     ALERT(Tab_Key)                 !!Alert Tab Key
  1072.     ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  1073.     @Alert                     !Alert Hot Key
  1074.     ACCEPT                     !Read A Field
  1075.     Mem:Message = ''                 !Clear Message Area
  1076.     @TableHot                     !On Hot Key, Call Procedure
  1077.     IF KEYCODE() = REJECT_KEY             !!If Reject Key Pressed
  1078.       BREAK                     !!  Return
  1079.     ELSIF KEYCODE() = Shft_Tab    |         !!If Shft_Tab Pressed
  1080.     AND FIELD() ~= ?First_Field             !!And Not First Field
  1081.       UPDATE(?)                     !!  Update Current Field
  1082.       SELECT(?-1)                 !!  Go Back One Field
  1083.     ELSIF KEYCODE() = Tab_Key             !!Elsif Tab Key Pressed
  1084.       UPDATE(?)                     !!  Update Current Field
  1085.     .                         !!.
  1086.  
  1087.     Edit_Range# = FIELD()             !Set One Field Edit Range
  1088.     IF KEYCODE() = Accept_Key  |         !On Screen Accept Key
  1089.     AND Edit_Range# <> ?Point             ! And Not On The Point Field
  1090.       UPDATE                     !  Move All Fields From Screen
  1091.       Edit_Range# = ?Point - 1             !  And Edit Remaining Fields
  1092.       SELECT(?Point)                 !  If Ok Then Start Here Next
  1093.     .                         !
  1094.  
  1095.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  1096.  
  1097.       CASE Field#                 !Jump To Field Edit Routine
  1098.  
  1099.       OF ?First_Field                 !From The First Field
  1100.     IF KEYCODE() = Esc_Key    |         !  Return On Esc Key
  1101.     OR Records# = False             !  Or No Records
  1102.       FREE(Table)                 !  Free The Table Of Points
  1103.       RETURN                 !  Return To Caller
  1104.     .
  1105.     @Edits                     !Edit Routines Go Here
  1106.     Records# = True                 !  Assume There Are Records
  1107.     @InitLocate
  1108.       OF ?Point                     !Process The Point Field
  1109.     IF ~RECORDS(Table)             !If There Are No Records
  1110.       IF Add_Ok                 !! If Ok To Add Records
  1111.         CLEAR(@Pre:Record)             !    Clear Record Area
  1112.         UPDATE                 !    Update All Fields
  1113.         Action = eAdd             !    Set Action To Add
  1114.         @AutoNumKey                 !    Auto Increment Key Field
  1115.         @TOTCHECK                 !  SAVE TOTAL FIELD AMOUNT
  1116.         @Update                 !    Call Form For First Record
  1117.         IF ~Action                 !    If Record Was Added
  1118.           DO Add_Table             !    Then Add New Table Entry
  1119.           DO Sort_Table             !    Sort The Table
  1120.           DO Show_Table             !    And Display First Page
  1121.         .                     !    .
  1122.         IF ~RECORDS(Table)             !    If Add Aborted Try Again
  1123.         Records# = False         !    Indicate No Records
  1124.         SELECT(?-1)             !    Select Previous Field
  1125.         BREAK                 !    End The Edits
  1126.         .                     !    .
  1127.         CYCLE                 !    Continue The Edit
  1128.       ELSE                     !! Else (Adds Not Allowed)
  1129.         NoRecs                 !!   Inform User
  1130.         SELECT(?-1)                 !!   Select Previous Field
  1131.         BREAK                 !!   End The Edits
  1132.     . .                     !. .
  1133.     @Locate
  1134.     CASE KEYCODE()                 !Process The Keystroke
  1135.  
  1136.     OF Enter_Key                 !Enter Key Or
  1137.     OROF Accept_Key                 !Ctrl-Enter Key
  1138.       DO Get_Record                 !  Read The Selected Record
  1139.       IF ERROR()                 !  If Record Has Been Deleted
  1140.         Mem:Message = ERROR()         !    Tell User What Happened
  1141.         SELECT(?)                 !    Stay In The Point Field
  1142.         DO Build_Table             !    Rebuild Table
  1143.         DO Sort_Table             !    Sort It
  1144.         DO Show_Table             !    Show It
  1145.         BREAK                 !    And Get Another Key
  1146.       .
  1147.       IF Action = eView         |         !  If This Is A Lookup Request
  1148.       AND KEYCODE() = Enter_Key
  1149.         Action = eDone             !    Set Action To Complete
  1150.         FREE(Table)                 !    Free The Table Of Points
  1151.         RETURN                 !    Return To Caller
  1152.       .
  1153.       IF Chg_Ok                 !! If Ok To Add Records
  1154.         Action = eChange             !    Set Action To Change
  1155.       @TOTSAVE                 !  SAVE TOTAL FIELD AMOUNT
  1156.         @Update                 !    Call Form To Change Record
  1157.         IF ~Action                 !    If The Record Was Changed
  1158.         @TOTMINUS                 !    SUBTRACT OLD TOTAL AMOUNT
  1159.           DELETE(Table); ChkErr         !    Delete Old Table Entry
  1160.           DO Add_Table             !    Add New Table Entry
  1161.           DO Sort_Table             !    Sort The Table
  1162.           DO Show_Table             !    And Display That Page
  1163.         .                     !    .
  1164.       ELSE                     !! Else (Changes Not Allowed)
  1165.         Action = eView             !!   Set Action To View
  1166.         @Update                 !!   Call Proc To View Record
  1167.       .                     !!.
  1168.     OF Ins_Key                 !Ins Key
  1169.       IF Add_Ok                 !! If Ok To Add Records
  1170.         CLEAR(@Pre:Record)             !    Clear Record Area
  1171.         Update                 !    Update All Fields
  1172.         Action = eAdd             !    Set Action To Add
  1173.         @AutoNumKey                 !    Auto Increment Key Field
  1174.         @Update                 !    Call Form For New Record
  1175.         IF ~Action                 !    If Record Was Added
  1176.           DO Add_Table             !    Add New Table Entry
  1177.           DO Sort_Table             !    Sort The Table
  1178.           DO Show_Table             !    And Display That Page
  1179.         .                     !    .
  1180.       ELSE                     !! Else (Adds Not Allowed)
  1181.         MEM:MESSAGE='You may not add records!'!!  Set Error Message
  1182.         BEEP                 !!   Beep
  1183.       .                     !!.
  1184.     OF Del_Key                 !Del Key
  1185.       IF Del_Ok                 !! If Ok To Delete Records
  1186.         DO Get_Record             !    Read The Selected Record
  1187.         IF ERROR()                 !    If Record Has Been Deleted
  1188.           Mem:Message = ERROR()         !    Tell User What Happened
  1189.           SELECT(?)                 !    Stay On The Point Field
  1190.           DO Build_Table             !    Rebuild Table
  1191.           DO Sort_Table             !    Sort It
  1192.           DO Show_Table             !    Show It
  1193.           Break                 !    And Get Another Key
  1194.         .                     !    .
  1195.       @TOTSAVE                 !  SAVE TOTAL FIELD AMOUNT
  1196.         Action = eDelete             !    Set Action To Delete
  1197.         @Update                 !    Call Form To Delete Record
  1198.         IF ~Action                 !    If Record Was Deleted
  1199.         @TOTMINUS                 !    SUBTRACT FROM TOTAL FLDS
  1200.           DELETE(Table); ChkErr         !    Delete Table Entry
  1201.           DO Show_Table             !    And Display That Page
  1202.         .                     !    .
  1203.       ELSE                     !! Else (Deletes Not Allowed)
  1204.         Mem:Message='You may not delete records!'!! Inform User
  1205.         BREAK                     !! Break From Edits
  1206.       .
  1207.     OF Down_Key                 !Down Arrow Key
  1208.       IF Ptr <= RECORDS(Table)-Count     !  If There Are More Entries
  1209.         SCROLL(Row,Col,Rows,Cols,ROWS(?Point)) !  Scroll The Screen Up
  1210.         Ptr += 1                 !    Set To The Next Entry
  1211.         DO Show_Record             !    And Display The Record
  1212.       .
  1213.     OF PgDn_Key                 !Page Down Key
  1214.       IF Ptr >= RECORDS(Table)-Count+1     !  On The Last Page
  1215.         Ndx = Count                 !    Point To Bottom Item
  1216.       .
  1217.       Ptr += Count                 !  Otherwise
  1218.       TblPtr = -1                 !  Not Set To A Record
  1219.       DO Show_Table                 !    Display The Next Page
  1220.  
  1221.     OF Ctrl_PgDn                 !Ctrl-Page Down Key
  1222.       Ptr = RECORDS(Table) - Count + 1     !  Set To Last Page
  1223.       Ndx = Count                 !  Point To Bottom Item
  1224.       TblPtr = -1                 !  Not Set To A Record
  1225.       DO Show_Table                 !  Display The Last Page
  1226.  
  1227.     OF Up_Key                 !Up Arrow Key
  1228.       IF Ptr > 1                 !  If There Is A Prior Record
  1229.         Ptr -= 1                 !    Set To Prior Record
  1230.         SCROLL(Row,Col,Rows,Cols,-(ROWS(?Point)))! Scroll The Screen Down
  1231.         DO Show_Record             !    Display The Record
  1232.       .
  1233.     OF PgUp_Key                 !Page Up Key
  1234.       IF Ptr = 1 THEN Ndx = 1.         !  On First Page Point To Top
  1235.       Ptr -= Rows                 !  Otherwise Back Up 1 Page
  1236.       TblPtr = -1                 !  Not Set To A Record
  1237.       DO Show_Table                 !  And Display It
  1238.  
  1239.     OF Ctrl_PgUp                 !Ctrl-Page Up
  1240.       Ptr = 1                 !  Point To First Record
  1241.       Ndx = 1                 !  Point To Top Item
  1242.       TblPtr = -1                 !  Not Set To A Record
  1243.       DO Show_Table                 !  And Display The First Page
  1244.   . . . .                     !
  1245.  
  1246.   FREE(Table)                     !Free Memory Table
  1247.   RETURN                     !And Return To Caller
  1248.  
  1249. Build_Table ROUTINE                 !Build Memory Table
  1250.   Free(Table)         !!Redundant With Readtable     !Empty The Table
  1251.   Clear(@Pre:Record) !!Redundant With Readtable !Make Sure Record Cleared
  1252.   @TOTCLEAR                     !ZERO TOTAL FIELDS
  1253.   @Restselects         !!Redundant With Readtable     !Restore Selector Criteria
  1254. ! Update         !!Causes Partial Tables     !Update All Fields
  1255. ! #Result         !!Causes Partial Tables     !Do Computed Fields Results
  1256.   @ReadTable                     !Do Selector Or Filter
  1257.   TblPtr = -1                     !Initialize To No Record
  1258.   DO Show_Table                     !Display A Page Of Records
  1259.  
  1260. Add_Table ROUTINE                 !Add Entry To Memory Table
  1261.   @CheckAdd                     !
  1262.   IF ~(@Filter) THEN EXIT.             !  Exit If Filtered Out
  1263.   @SetComponents                 !  Move Key Components
  1264.   TblPtr = POINTER(@FileName)             !  Save Data Record Pointer
  1265.   ADD(Table)                     !  Add New Table Entry
  1266.   IF ERROR()                     !  If Out Of Memory
  1267.     Mem:Message = ERROR()             !    Inform User
  1268.     BEEP                     !    Sound Alarm
  1269.   .
  1270.   @TOTALCALCSEL                     !CALCULATE TOTAL FIELDS
  1271.  
  1272. Sort_Table ROUTINE                 !Sort Table Entries
  1273.   TblPtr# = TblPtr                 !  Save Data Record Pointer
  1274.   @SortTable                     !  Sort The Table
  1275.   LOOP Ptr = 1 TO RECORDS(Table)         !  Look Up The Saved Pointer
  1276.     GET(Table,Ptr); ChkErr             !    So We Will Still Point
  1277.     IF TblPtr = TblPtr# THEN EXIT.         !    At The Same Record
  1278.   .
  1279.  
  1280. Show_Table ROUTINE                 !Display A Page Of Records
  1281.   IF Ptr > RECORDS(Table)-Count+1         !  For A Partial Page
  1282.     Ptr = RECORDS(Table)-Count+1         !    Set To The Last Record
  1283.   .
  1284.   IF Ptr < 1 THEN Ptr = 1.             !    And Back Up One Page
  1285.   TblPtr# = TblPtr                 !  Save Data Record Pointer
  1286.   Ndx# = Ndx                     !  Save Repeat Index
  1287.   LOOP Ndx = 1 TO Count                 !  Loop Thru The Scroll Area
  1288.     IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  1289.     DO Show_Record                 !    Display A Record
  1290.     IF TblPtr# = TblPtr THEN Ndx# = Ndx.     !    Point To Correct Record
  1291.   .                         !
  1292.   Ndx = Ndx#                     !  Restore Repeat Index
  1293.   IF Ndx > RECORDS(Table) THEN Ndx = RECORDS(Table).!Showing The Last
  1294.   CLEAR(@Pre:Record)                 !  Clear Record Area
  1295.   IF RECORDS(Table) < Count             !  If Records Do Not Fill
  1296.      Ndx#= RECORDS(Table) * @PRows         !     Get Number Times Size
  1297.      BLANK(Row+Ndx#,Col,Rows-Ndx#,Cols)         !     Blank Remaining Area
  1298.   .
  1299.   Relocate_# = False
  1300.  
  1301. Show_Record ROUTINE                 !Display A Record
  1302.   TblPtr = 0                     !  Start With No Record
  1303.   GET(Table,Ptr+Ndx-1)                 !  Get The Table Entry
  1304.   IF ~ERROR()                     !  If There Is One
  1305.     GET(@FileName,TblPtr)             !    Read A Data Record
  1306.     IF ~ERROR()
  1307.       @RestSelects                 !    Restore Selector Fields
  1308.     ! #LookupScroll                 !    Display From Other Files
  1309.     ! #ShowScroll                 !    Display String Variables
  1310.     ! #ComputeScroll                 !    Display Computed Fields
  1311.     ! #ConditionalScrl                 !    Display Conditional Fields
  1312.     ! #ResultScroll                 !    Assign Result Fields
  1313.       DO SHOW_LINE                 !    DISPLAY SCROLLING LINE
  1314.   . .
  1315.  
  1316. SHOW_LINE    ROUTINE                 !DISPLAY SCROLLING LINE
  1317.   @LOOKUPSCROLL                     !    DISPLAY FROM OTHER FILES
  1318.   @SHOWSCROLL                     !    DISPLAY STRING VARIABLES
  1319.   @COMPUTESCROLL                 !    DISPLAY COMPUTED FIELDS
  1320.   @CONDITIONALSCRL                 !    DISPLAY CONDITIONAL FIELDS
  1321.   @RESULTSCROLL                     !    ASSIGN RESULT FIELDS
  1322.  
  1323. Get_Record ROUTINE                 !Read Selected Record
  1324.   GET(Table,Ptr+Ndx-1); ChkErr             !  Get The Table Entry
  1325.   GET(@FileName,TblPtr); ChkErr             !  Read The Data Record
  1326.  
  1327. Find_Record ROUTINE                 !Locate Requested Record
  1328.   @SetComponents                 !  Move Them To The Table
  1329.   IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  1330.   GET(Table,Key)                 !  Get The Table Entry
  1331.   IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  1332.   Ptr = POINTER(Table)                 !  Set Record Pointer
  1333.   IF ~Ptr THEN Ptr = RECORDS(Table).         !  Set To Last If No Pointer
  1334.   GET(Table,Ptr); ChkErr             !  And Read The Data Record
  1335.   IF Relocate_# AND (INRANGE(KEYBOARD(),32,254) OR KEYBOARD()=BS_Key); EXIT.
  1336.   DO Show_Table                     !  Display That Page
  1337.  
  1338. Same_Page ROUTINE                 !Set To Same Page Routine
  1339.   DO Sort_Table                     !  Sort The Table
  1340.  
  1341. @COMPUTETOTS                     !CALCULATE TOTAL FIELDS
  1342. *NormForm***********************************************************************
  1343. @ProcName    PROCEDURE                 !Normal Form With View
  1344.  
  1345. Screen         SCREEN      PRE(Scr),@ScreenOpt
  1346.               @Paints
  1347.               @Strings
  1348.               @Variables
  1349.               ENTRY,USE(?First_Field)
  1350.               @Fields
  1351.               @Pause
  1352.               ENTRY,USE(?Last_Field)
  1353.               PAUSE(''),USE(?Pause)     !!Change To ?Pause
  1354.          .
  1355.  
  1356.   EJECT
  1357.   CODE
  1358.   OPEN(Screen)                     !Open The Screen
  1359.   SETCURSOR                     !Turn Off Any Cursor
  1360.   @Setup                     !Call Setup Procedure
  1361.   DISPLAY                     !Display The Fields
  1362.   EXECUTE Action                 !Set The Current Record Pointer
  1363.     Pointer# = 0                 !  No Record For Add
  1364.     Pointer# = POINTER(@FileName)         !  Current Record For Change
  1365.     Pointer# = POINTER(@FileName)         !  Current Record For Delete
  1366.     Pointer# = POINTER(@FileName)         !! Current Record For View
  1367.   .
  1368.   LOOP                         !Loop Thru All The Fields
  1369.     Mem:Message = CENTER(Mem:Message)         !!Center Action Message
  1370.     @Lookups                     !Display From Other Files
  1371.     @Show                     !Display String Variables
  1372.     @Compute                     !Display Computed Fields
  1373.     @Conditional                 !Display Conditional Fields
  1374.     @Result                     !Move Resulting Values
  1375.     ALERT                     !Reset Alerted Keys
  1376.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  1377.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  1378.     @Alert                     !Alert Hot Key
  1379.     ACCEPT                     !Read A Field
  1380.     @CheckHot                     !On Hot Key, Call Procedure
  1381.     IF KEYCODE() = Reject_Key THEN RETURN.     !Return On Screen Reject Key
  1382.     EXECUTE Action                 !Set Action Message
  1383.       Mem:Message = 'Record will be added'     !
  1384.       Mem:Message = 'Record will be changed'     !
  1385.       Mem:Message = 'Press <<Enter> to delete'     !
  1386.       Mem:Message = 'Press <<Enter> to continue' !!
  1387.     .                         !
  1388.     Edit_Range# = FIELD()             !Set One Field Edit Range
  1389.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  1390.       UPDATE                     !  Move All Fields From Screen
  1391.       Edit_Range# = FIELDS()             !  And Edit Remaining Fields
  1392.     .                         !
  1393.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  1394.       CASE Field#                 !Jump To Field Edit Routine
  1395.       OF ?First_Field                 !From The First Field
  1396.     IF KEYCODE() = Esc_Key THEN RETURN.     !  Return On Esc Key
  1397.     IF Action = eDelete OR Action = eView     !! If Action Is Delete Or View
  1398.       SELECT(?Pause)             !!   Select Pause Field
  1399.     .                     !! .
  1400.  
  1401.       @Edits                     !Edit Routines Go Here
  1402.       OF ?Last_Field                 !From The Last Field
  1403.     EXECUTE Action                 !  Update The File
  1404.       ADD(@FileName)             !    Add New Record
  1405.       PUT(@FileName)             !    Change Existing Record
  1406.       DELETE(@FileName)             !    Delete Existing Record
  1407.     .                     !  .
  1408.     ChkErr                     !  Check For Errors
  1409.     PUT(@FileName2); ChkErr             !  Update Secondary Files
  1410.     PUT(@FileName3); ChkErr             !  Update Secondary Files
  1411.     PUT(@FileName4); ChkErr             !  Update Secondary Files
  1412.     @NextForm                 !  Call Next Form Procedure
  1413.     Action = eDone                 !  Set Action To Complete
  1414.     RETURN                     !  And Return To Caller
  1415.  
  1416.       OF ?Pause                     !From The Pause Field
  1417.     IF KEYCODE() = Enter_Key |         !  On Enter Key
  1418.     OR KEYCODE() = Accept_Key         !  Or Ctrl-Enter Key
  1419.       SELECT(?Last_Field)             !    Delete The Record
  1420.     ELSE                     !  Otherwise
  1421.       BEEP                     !    Beep And Ask Again
  1422.   . . . .
  1423.  
  1424. *Form***************************************************************************
  1425. @ProcName    PROCEDURE                 !Form With View, Up, Sh/Tab
  1426.  
  1427. Screen         SCREEN      PRE(Scr),@ScreenOpt
  1428.               @Paints
  1429.               @Strings
  1430.               @Variables
  1431.               ENTRY,USE(?First_Field)
  1432.               @Fields
  1433.               @Pause
  1434.               ENTRY,USE(?Last_Field)
  1435.               PAUSE(''),USE(?Pause)     !!Change To ?Pause
  1436.          .
  1437.  
  1438. Up_Ok         BYTE
  1439. Tab_Ok         BYTE
  1440.  
  1441.   EJECT
  1442.   CODE
  1443.   Changed_# = False
  1444.   OPEN(Screen)                     !Open The Screen
  1445.   SETCURSOR                     !Turn Off Any Cursor
  1446.   Up_Ok=True; Tab_Ok=True
  1447.   @Setup                     !Call Setup Procedure
  1448.   DISPLAY                     !Display The Fields
  1449.   EXECUTE Action                 !Set The Current Record Pointer
  1450.     Pointer# = 0                 !  No Record For Add
  1451.     Pointer# = POINTER(@FileName)         !  Current Record For Change
  1452.     Pointer# = POINTER(@FileName)         !  Current Record For Delete
  1453.     Pointer# = POINTER(@FileName)         !! Current Record For View
  1454.   .
  1455.   LOOP                         !Loop Thru All The Fields
  1456.     Mem:Message = CENTER(Mem:Message)         !!Center Action Message
  1457.     @Lookups                     !Display From Other Files
  1458.     @Show                     !Display String Variables
  1459.     @Compute                     !Display Computed Fields
  1460.     @Conditional                 !Display Conditional Fields
  1461.     @Result                     !Move Resulting Values
  1462.     ALERT                     !Reset Alerted Keys
  1463.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  1464.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  1465.     IF Up_Ok
  1466.       ALERT(Up_Key)                 !!Alert Cursor Up Key
  1467.     .
  1468.     IF Tab_Ok
  1469.       ALERT(Tab_Key)                 !!Alert Tab Key
  1470.       ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  1471.     .
  1472.     @Alert                     !Alert Hot Key
  1473.     ACCEPT                     !Read A Field
  1474.     IF REFER() THEN Changed_# = TRUE.
  1475.     @CheckHot                     !On Hot Key, Call Procedure
  1476.     IF KEYCODE() = Reject_Key             !!If Reject Key Pressed
  1477.       IF Changed_#
  1478.     CASE AbortEditYN_()
  1479.       OF 'Y'; RETURN
  1480.       OF 'N'; SELECT(?)
  1481.           CYCLE
  1482.       OF 'S'; SELECT(?Last_Field)
  1483.           CYCLE
  1484.     .
  1485.       ELSE
  1486.     RETURN
  1487.       .
  1488.     ELSIF (KEYCODE() = Up_Key         |         !!Elsif (Up_Key Pressed
  1489.     OR KEYCODE()     = Shft_Tab)     |         !!Or Shft_Tab Pressed)
  1490.     AND FIELD()         > ?First_Field         !!And Not First Field
  1491.       UPDATE(?)                     !!  Update Current Field
  1492.       SELECT(?-1)                 !!  Go Back One Field
  1493.       CYCLE                     !!  Loop For More Field Input
  1494.     ELSIF KEYCODE() = Tab_Key             !!Elsif Tab Key Pressed
  1495.       UPDATE(?)                     !!  Update Current Field
  1496.     .                         !!.
  1497.  
  1498.     EXECUTE Action                 !Set Action Message
  1499.       Mem:Message = 'Record will be added'     !
  1500.       Mem:Message = 'Record will be changed'     !
  1501.       Mem:Message = 'Press <<Enter> to delete'     !
  1502.       Mem:Message = 'Press <<Enter> to continue' !!
  1503.     .
  1504.     Edit_Range# = FIELD()             !Set One Field Edit Range
  1505.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  1506.       UPDATE                     !  Move All Fields From Screen
  1507.       Edit_Range# = FIELDS()             !  And Edit Remaining Fields
  1508.     .                         !
  1509.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  1510.       CASE Field#                 !Jump To Field Edit Routine
  1511.       OF ?First_Field                 !From The First Field
  1512.     IF KEYCODE() = Esc_Key             !  Return On Esc Key
  1513.       IF Changed_#
  1514.         CASE AbortEditYN_()
  1515.           OF 'Y'; RETURN
  1516.           OF 'N'; SELECT(?)
  1517.               BREAK
  1518.           OF 'S'; SELECT(?Last_Field)
  1519.               Field# = ?Last_Field-1
  1520.               CYCLE
  1521.         .
  1522.       ELSE
  1523.         RETURN
  1524.       .
  1525.     ELSIF Action = eDelete OR Action = eView !! If Action Is Delete Or View
  1526.       SELECT(?Pause)             !!   Select Pause Field
  1527.       BREAK
  1528.     .                     !! .
  1529.  
  1530.       @Edits                     !Edit Routines Go Here
  1531.       OF ?Last_Field                 !From The Last Field
  1532.     EXECUTE Action                 !  Update The File
  1533.       ADD(@FileName)             !    Add New Record
  1534.       PUT(@FileName)             !    Change Existing Record
  1535.       DELETE(@FileName)             !    Delete Existing Record
  1536.     .                     !  .
  1537.     ChkErr                     !  Check For Errors
  1538.     PUT(@FileName2); ChkErr             !  Update Secondary Files
  1539.     PUT(@FileName3); ChkErr             !  Update Secondary Files
  1540.     PUT(@FileName4); ChkErr             !  Update Secondary Files
  1541.     @NextForm                 !  Call Next Form Procedure
  1542.     Action = eDone                 !  Set Action To Complete
  1543.     RETURN                     !  And Return To Caller
  1544.  
  1545.       OF ?Pause                     !From The Delete/View Field
  1546.     IF KEYCODE() = Enter_Key |         !  On Enter Key
  1547.     OR KEYCODE() = Accept_Key         !  Or Ctrl-Enter Key
  1548.       SELECT(?Last_Field)             !    Delete The Record
  1549.     ELSE                     !  Otherwise
  1550.       BEEP                     !    Beep And Ask Again
  1551.   . . . .
  1552.  
  1553. *NormMemForm********************************************************************
  1554. @ProcName    PROCEDURE
  1555.  
  1556. Screen         SCREEN      PRE(Scr),@ScreenOpt
  1557.               @Paints
  1558.               @Strings
  1559.               @Variables
  1560.               ENTRY,USE(?First_Field)
  1561.               @Fields
  1562.               @Pause
  1563.               ENTRY,USE(?Last_Field)
  1564.          .
  1565.  
  1566.   EJECT
  1567.   CODE
  1568.   OPEN(Screen)                     !Open The Screen
  1569.   SETCURSOR                     !Turn Off Any Cursor
  1570.   @Setup                     !Call Setup Procedure
  1571.   DISPLAY                     !Display The Fields
  1572.   LOOP                         !Loop Thru All The Fields
  1573.     Mem:Message = CENTER(Mem:Message)         !Center Action Message
  1574.     @Lookups                     !Display From Other Files
  1575.     @Show                     !Display String Variables
  1576.     @Compute                     !Display Computed Fields
  1577.     @Conditional                 !Display Conditional Fields
  1578.     @Result                     !Move Resulting Values
  1579.     ALERT                     !Reset Alerted Keys
  1580.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  1581.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  1582.     @Alert                     !Alert Hot Key
  1583.     ACCEPT                     !Read A Field
  1584.     @CheckHot                     !On Hot Key, Call Procedure
  1585.     IF KEYCODE() = Reject_Key THEN RETURN.     !Return On Screen Reject Key
  1586.     Edit_Range# = FIELD()             !Set One Field Edit Range
  1587.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  1588.       UPDATE                     !  Move All Fields From Screen
  1589.       Edit_Range# = FIELDS()             !  And Edit Remaining Fields
  1590.     .                         !
  1591.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  1592.       CASE Field#                 !Jump To Field Edit Routine
  1593.       OF ?First_Field                 !From The First Field
  1594.     IF KEYCODE() = Esc_Key THEN RETURN.     !  Return On Esc Key
  1595.  
  1596.       @Edits                     !Edit Routines Go Here
  1597.       OF ?Last_Field                 !From The Last Field
  1598.     PUT(@FileName2); ChkErr             !  Update Secondary Files
  1599.     PUT(@FileName3); ChkErr             !  Update Secondary Files
  1600.     PUT(@FileName4); ChkErr             !  Update Secondary Files
  1601.     @NextForm                 !  Call Next Form Procedure
  1602.     Action = eDone                 !  Set Action To Complete
  1603.     RETURN                     !  And Return To Caller
  1604.   . . .
  1605.  
  1606. *MemForm************************************************************************
  1607. @ProcName    PROCEDURE
  1608.  
  1609. Screen         SCREEN      PRE(Scr),@ScreenOpt
  1610.               @Paints
  1611.               @Strings
  1612.               @Variables
  1613.               ENTRY,USE(?First_Field)
  1614.               @Fields
  1615.               @Pause
  1616.               ENTRY,USE(?Last_Field)
  1617.          .
  1618.  
  1619.   EJECT
  1620.   CODE
  1621.   OPEN(Screen)                     !Open The Screen
  1622.   SETCURSOR                     !Turn Off Any Cursor
  1623.   @Setup                     !Call Setup Procedure
  1624.   DISPLAY                     !Display The Fields
  1625.   LOOP                         !Loop Thru All The Fields
  1626.     Mem:Message = CENTER(Mem:Message)         !Center Action Message
  1627.     @Lookups                     !Display From Other Files
  1628.     @Show                     !Display String Variables
  1629.     @Compute                     !Display Computed Fields
  1630.     @Conditional                 !Display Conditional Fields
  1631.     @Result                     !Move Resulting Values
  1632.     ALERT                     !Reset Alerted Keys
  1633.     ALERT(Accept_Key)                 !Alert Screen Accept Key
  1634.     ALERT(Reject_Key)                 !Alert Screen Reject Key
  1635.     ALERT(Up_Key)                 !!Alert Cursor Up Key
  1636.     ALERT(Tab_Key)                 !!Alert Tab Key
  1637.     ALERT(Shft_Tab)                 !!Alert Shift-Tab Key
  1638.     @Alert                     !Alert Hot Key
  1639.     ACCEPT                     !Read A Field
  1640.     @CheckHot                     !On Hot Key, Call Procedure
  1641.     IF KEYCODE() = Reject_Key             !!If Reject Key Pressed
  1642.       RETURN                     !!  Return
  1643.     ELSIF (KEYCODE() = Up_Key         |         !!Elsif (Up_Key Pressed
  1644.     OR KEYCODE()     = Shft_Tab)     |         !!Or Shft_Tab Pressed)
  1645.     AND FIELD()        ~= ?First_Field         !!And Not First Field
  1646.       UPDATE(?)                     !!  Update Current Field
  1647.       SELECT(?-1)                 !!  Go Back One Field
  1648.       CYCLE                     !!  Loop For More Field Input
  1649.     ELSIF KEYCODE() = Tab_Key             !!Elsif Tab Key Pressed
  1650.       UPDATE(?)                     !!  Update Current Field
  1651.     .                         !!.
  1652.  
  1653.     Edit_Range# = FIELD()             !Set One Field Edit Range
  1654.     IF KEYCODE() = Accept_Key             !On Screen Accept Key
  1655.       UPDATE                     !  Move All Fields From Screen
  1656.       Edit_Range# = FIELDS()             !  And Edit Remaining Fields
  1657.     .                         !
  1658.     LOOP Field# = FIELD() TO Edit_Range#     !Edit Fields In The Edit Range
  1659.       CASE Field#                 !Jump To Field Edit Routine
  1660.       OF ?First_Field                 !From The First Field
  1661.     IF KEYCODE() = Esc_Key THEN RETURN.     !  Return On Esc Key
  1662.  
  1663.       @Edits                     !Edit Routines Go Here
  1664.       OF ?Last_Field                 !From The Last Field
  1665.     PUT(@FileName2); ChkErr             !  Update Secondary Files
  1666.     PUT(@FileName3); ChkErr             !  Update Secondary Files
  1667.     PUT(@FileName4); ChkErr             !  Update Secondary Files
  1668.     @NextForm                 !  Call Next Form Procedure
  1669.     Action = eDone                 !  Set Action To Complete
  1670.     RETURN                     !  And Return To Caller
  1671.   . . .
  1672.  
  1673. *Report*************************************************************************
  1674.  
  1675. @PROCNAME    PROCEDURE
  1676.  
  1677. REPORT         @REPORT
  1678.  
  1679. @SAVEITEMS
  1680.  
  1681.   CODE
  1682.   DONE# = 0                     !TURN OFF DONE FLAG
  1683.   @SETUP                     !CALL SETUP PROCEDURE
  1684.   @INITSELECTS                     !SAVE SELECTOR FIELDS
  1685.   CLEAR(@PRE:RECORD)                 !MAKE SURE RECORD CLEARED
  1686.   @RESTSELECTS                     !RESTORE SELECTOR CRITERIA
  1687.   BUILD(@INDEX)                     !BUILD FILE INDEX
  1688.   @INITREPORT                     !INIT REPORT VARIABLES
  1689.   @RPTHEADER                     !DO REPORT HEADER COMPUTES
  1690.   PRINT(TTL:RPT_HEAD)                 !PRINT TITLE PAGE
  1691.   @PRINTMEMO                     !PRINT ANY MEMO FILES
  1692.   CLOSE(TITLE)                     !CLOSE TITLE REPORT
  1693.   @SETFILE                     !SET TO FIRST RECORD
  1694.   @PAGEFOOTER                     !DO PAGE FOOTER COMPUTES
  1695.   @PAGEHEADER                     !DO PAGE HEADER COMPUTES
  1696.   DO NEXT_RECORD                 !READ FIRST RECORD
  1697.   @PAGEHEADER                     !DO PAGE HEADER COMPUTES
  1698.   OPEN(REPORT)                     !OPEN THE REPORT
  1699.   @FIRSTBREAK                     !PRINT INITIAL BREAK HEADERS
  1700.   LOOP UNTIL DONE#                 !READ ALL RECORDS IN FILE
  1701.     SAVE_LINE# = MEM:LINE             !  SAVE LINE NUMBER
  1702.     LAST_REC# = POINTER(@FILENAME)
  1703.     @RUNTOTALS                     !  ACCUMULATE RUNNING TOTALS
  1704.     @INITDETAIL                     !  SET UP FOR DETAIL LINE
  1705.     PRINT(RPT:DETAIL)                 !  PRINT DETAIL LINES
  1706.     DO CHECK_PAGE                 !  DO PAGE BREAK IF NEEDED
  1707.     @PRINTMEMO                     !  PRINT ANY MEMO FIELD
  1708.     @TOTALS                     !  ACCUMULATE TOTALS
  1709.     @PAGEFOOTER                     !  DO PAGE FOOTER COMPUTES
  1710.     @PAGEHEADER                     !  DO PAGE HEADER COMPUTES
  1711.     @PAGEEJECT                     !  GO TO NEW PAGE
  1712.     DO NEXT_RECORD                 !  GET NEXT RECORD
  1713.     @CHECKBREAK                     !  CHECK FOR BREAK
  1714.   .                         !
  1715.   @LASTBREAK                     !  PRINT ENDING BREAK FOOTERS
  1716.   @RPTFOOTER                     !DO REPORT FOOTER COMPUTES
  1717.   PRINT(RPT:RPT_FOOT)                 !PRINT GRAND TOTALS
  1718.   DO CHECK_PAGE                     !  DO PAGE BREAK IF NEEDED
  1719.   @PRINTMEMO                     !  PRINT ANY MEMO FIELD
  1720.   CLOSE(REPORT)                     !CLOSE REPORT
  1721.   RETURN                     !RETURN TO CALLER
  1722.  
  1723.  
  1724. NEXT_RECORD ROUTINE                 !GET NEXT RECORD
  1725.   LOOP UNTIL EOF(@FILENAME)             !  READ UNTIL END OF FILE
  1726.     NEXT(@FILENAME)                 !    READ NEXT RECORD
  1727.     @CHECKSELECT                 !    STOP IF PAST SELECTOR
  1728.     @DETAIL                     !    DO DETAIL COMPUTES
  1729.     IF ~(@FILTER) THEN CYCLE.             !    IF FILTERED OUT, GET NEXT
  1730.     EXIT                     !    EXIT THE ROUTINE
  1731.   .                         !
  1732.   DONE# = 1                     !  ON EOF, SET DONE FLAG
  1733.  
  1734. CHECK_PAGE ROUTINE                 !CHECK FOR NEW PAGE
  1735.   IF MEM:LINE <= SAVE_LINE#             !  ON PAGE OVERFLOW
  1736.     SAVE_LINE# = MEM:LINE             !    RESET LINE NUMBER
  1737.     @INITPAGE                     !    INIT PAGE VARIABLES
  1738.   .
  1739.   LOOP UNTIL NOT KEYBOARD()             !LOOK FOR KEYSTROKE
  1740.     ASK
  1741.     IF KEYCODE() = REJECT_KEY THEN RETURN.     !ABORT REPORT
  1742.   .
  1743.  
  1744. @BREAKRTN                     !CHECK FOR GROUP BREAK
  1745. *MemReport**********************************************************************
  1746.  
  1747.  
  1748. @PROCNAME    PROCEDURE
  1749.  
  1750. REPORT         @REPORT
  1751.  
  1752.   CODE
  1753.   @SETUP                     !CALL SETUP PROCEDURE
  1754.   @INITREPORT                     !INIT REPORT VARIABLES
  1755.   @RPTHEADER                     !DO REPORT HEADER COMPUTES
  1756.   PRINT(TTL:RPT_HEAD)                 !PRINT TITLE PAGE
  1757.   @MEMMEMO                     !PRINT ANY MEMO FILES
  1758.   CLOSE(TITLE)                     !CLOSE TITLE REPORT
  1759.   @PAGEFOOTER                     !DO PAGE FOOTER COMPUTES
  1760.   @PAGEHEADER                     !DO PAGE HEADER COMPUTES
  1761.   OPEN(REPORT)                     !OPEN REPORT BODY
  1762.   @MEMMEMO                     !PRINT ANY MEMO FIELD
  1763.   @DETAIL                     !DO DETAIL COMPUTES
  1764.   @RUNTOTALS                     !ACCUMULATE RUNNING TOTALS
  1765.   @INITDETAIL                     !SET UP FOR DETAIL RECORD
  1766.   PRINT(RPT:DETAIL)                 !PRINT DETAIL LINES
  1767.   @MEMMEMO                     !PRINT ANY MEMO FIELD
  1768.   @TOTALS                     !ACCUMULATE TOTALS
  1769.   @MEMMEMO                     !PRINT ANY MEMO FIELD
  1770.   @PAGEFOOTER                     !DO PAGE FOOTER COMPUTES
  1771.   @RPTFOOTER                     !DO REPORT FOOTER COMPUTES
  1772.   PRINT(RPT:RPT_FOOT)                 !PRINT REPORT FOOTER
  1773.   @MEMMEMO                     !PRINT ANY MEMO FIELD
  1774.   CLOSE(REPORT)                     !CLOSE REPORT
  1775.   RETURN                     !RETURN TO CALLER
  1776. *PrintMemo**********************************************************************
  1777.       @MemoLen                     !Determine Memo Size
  1778.       J# = 2                     !Start With Second Row
  1779.       LOOP                     !Loop Thru All Used Rows
  1780.     MemoDone# = False             !! No Memos Done Yet
  1781.     @SetMemo                 !  Set The Memo Variables
  1782.     IF MemoDone# = False THEN BREAK.     !! All Memos Printed
  1783.     @PrtDetail                 !  And Print It
  1784.     J# += 1                     !  Increment Counter
  1785.     DO Check_Page                 !  Do Page Break If Needed
  1786.       .
  1787.       DO Check_Page                 !Do Page Break If Needed
  1788. *SetMemo************************************************************************
  1789.       IF J# <= @MemoTmp#             !If In The Range Of This Memo
  1790.         @MemoVar = @MemoRow[J#]         !  Move A Memo Field Row
  1791.         MemoDone# = True             !! Memo Has Been Moved
  1792.       ELSE                     !Otherwise
  1793.         @MemoVar = ''             !  No Memo To Do
  1794.       .                     ! End Of Setmemo
  1795. *MemoLen************************************************************************
  1796.       LOOP @MemoTmp# = @MemoSize TO 2 BY -1     !Backscan The Memo Field To
  1797.     IF @MemoRow[@MemoTmp#] <> '' THEN BREAK. ! Find Number Of Rows Used
  1798.       .                         ! End Of Memolen
  1799. *PrtDetail**********************************************************************
  1800.     Print(@MemDetail); ChkErr         !Print The Detail Record
  1801. *MemMemo************************************************************************
  1802.   @MemoLen                     !Determine Memo Size
  1803.   J# = 2                     !Start With Row 2
  1804.   LOOP                         !Loop Thru All Used Rows
  1805.     MemoDone# = False                 !! No Memos Done Yet
  1806.     @SetMemo                     !  Set The Memo Variables
  1807.     IF MemoDone# = False THEN BREAK.         !! All Memos Printed
  1808.     @PrtDetail                     !  And Print It
  1809.     J# += 1                     !  Increment Counter
  1810.   .
  1811. *Alert**************************************************************************
  1812.     ALERT(@HotKey)                 !Alert Hot Key
  1813. *ToDo***************************************************************************
  1814. @ProcName    PROCEDURE                 !This Procedure Is Not Defined
  1815.                          !!Add This Screen
  1816. Screen         SCREEN      WINDOW(4,42),AT(10,20),HUE(7,4)
  1817.            ROW(1,42)  PAINT(1,1),TRN
  1818.            ROW(4,1)      PAINT(1,1),TRN
  1819.            ROW(1,1)      STRING('╔═{39}╗'),ENH
  1820.            ROW(2,1)      STRING('║<0{39}>║'),ENH
  1821.            ROW(3,1)      STRING('╚═{39}╝'),ENH
  1822.            ROW(2,42)  REPEAT(2);STRING('░'),HUE(7,0) .
  1823.            ROW(4,2)      STRING('░{41}'),HUE(7,0)
  1824.            ROW(2,3)      STRING('This procedure hasn''t been completed!')    |
  1825.                 HUE(11,4)
  1826.          .
  1827.  
  1828.   CODE                         !Code Section
  1829.   OPEN(Screen)                     !!Open Screen
  1830.   BEEP                         !!Beep
  1831.   ASK                         !!Wait For A Keystroke
  1832.   RETURN                     !Return To Caller
  1833. *ShowMemo***********************************************************************
  1834.     R# = ROW(@ScrMemo)                 !Save Row Of Memo
  1835.     C# = COL(@ScrMemo)                 !Save Col Of Memo
  1836.     SETHUE(FOREHUE(R#,C#),BACKHUE(R#,C#))     !Retrieve Color Of Memo
  1837.     LOOP I# = 1 TO @MemoRows             !Display Memo Field By Rows
  1838.       SHOW(R#+I#-1,C#,@MemoRow[I#],@S@MemoCols)     !Show Next Row
  1839.     .
  1840.     SETHUE                     !Turn Off Color
  1841. *InRange************************************************************************
  1842.     IF ~INRANGE(@Field,@Lower,@Upper)     !If Field Is Out Of Range
  1843.       BEEP                     !  Sound Keyboard Alarm
  1844.       SELECT(?@Field)             !  And Stay On This Field
  1845.       BREAK                     !
  1846.     .
  1847. *Required***********************************************************************
  1848.     IF @Field = ''                 !If Required Field Is Empty
  1849.       BEEP                     !  Sound Keyboard Alarm
  1850.       SELECT(?@Field)             !  And Stay On This Field
  1851.       BREAK                     !
  1852.     .
  1853. *NotRequired********************************************************************
  1854.     IF @Field = ''                 !If Not Required Then
  1855.       @EditProc                 !  Call The Edit Procedure
  1856.       CYCLE                     !  End The Edit
  1857.     .
  1858. *UniqueKey**********************************************************************
  1859.     GET(@FileName,@AccessKey)         !Read The Record By Key
  1860.     IF NOT ERROR()                 !If A Record Is Found
  1861.       IF POINTER(@FileName) <> Pointer#     !  But Not The Same Record
  1862.         CLEAR(@Pre:Record)             !    Clear In Case Of Add
  1863.         IF Pointer#                 !!   If There Is A Current Rec
  1864.           GET(@FileName,Pointer#); ChkErr     !    Re-Read The Old Record
  1865.         .                     !!
  1866.         UPDATE                 !    Re-Update The Record
  1867.         Mem:Message='Creates duplicate key!' !    Move An Error Message
  1868.         SELECT(?@Field)             !    Stay On The Same Field
  1869.         BEEP                 !    Sound The Keyboard Alarm
  1870.         BREAK                 !    And Loop Again
  1871.     . .
  1872.     CLEAR(@Pre:Record)             !!Clear Record
  1873.     IF Pointer#                 !!If There Is A Current Rec
  1874.       GET(@FileName,Pointer#); ChkErr     !  Re-Read The Old Record
  1875.     .                     !!
  1876.     UPDATE                     !  And Re-Update The Record
  1877. *SetTop*************************************************************************
  1878.   SET(@KeyName); ChkErr                 !Set To First Record
  1879. *SetSelect**********************************************************************
  1880.   SET(@KeyName,@KeyName); ChkErr         !Set To First Selected Record
  1881. *InitLocate*********************************************************************
  1882.     OF ?Pre_Point                 !
  1883.       IF KEYCODE() = Esc_Key  |             !  If Going Up
  1884.       OR KEYCODE() = Up_Key   |             !    The Screen
  1885.       OR Records#  = False             !    Or No Records On Screen
  1886.     Scr:Locator = ''             !    Clear Locator
  1887.     SELECT(?-1)                 !    And Go To Previous Field
  1888.     SETCURSOR                 !    And Turn Cursor Off
  1889.       ELSE                     !  Otherwise, Going Down
  1890.     Len# = 0                 !    Reset To Start Of Locator
  1891.     SETCURSOR(ROW(Scr:Locator),COL(Scr:Locator)) !And Turn Cursor On
  1892.       .
  1893. *PrePoint***********************************************************************
  1894.               ENTRY,USE(?Pre_Point)
  1895. *Locate*************************************************************************
  1896.     LOOP
  1897.       IF Relocate_# THEN ASK.
  1898.       IF KEYCODE() > 31 |             !The Displayable Characters
  1899.       AND KEYCODE() < 255             !Are Used To Locate Records
  1900.         IF Len# < SIZE(Scr:Locator)         !  If There Is Room Left
  1901.           Scr:Locator = SUB(Scr:Locator,1,Len#) & CHR(KEYCODE())
  1902.           Len# += 1                 !    Increment The Length
  1903.         .
  1904.       ELSIF KEYCODE() = BS_Key         !Backspace Untypes A Character
  1905.         IF Len# > 0                 !  If There Are Characters Left
  1906.           Len# -= 1                 !    Decrement The Length
  1907.           Scr:Locator = SUB(Scr:Locator,1,Len#) ! Erase The Last Character
  1908.         .
  1909.       ELSE                     !For Any Other Character
  1910.         Len# = 0                 !  Zero The Length
  1911.         Scr:Locator = ''             !  Erase The Locator Field
  1912.         Relocate_# = False
  1913.       .
  1914.       SETCURSOR(ROW(Scr:Locator),COL(Scr:Locator)+Len#) !And Reset The Cursor
  1915.       @SetLocate
  1916.       IF KEYBOARD() > 31   |         !The Displayable Characters
  1917.       AND KEYBOARD() < 255 |         !Are Used To Locate Records
  1918.       OR KEYBOARD() = BS_Key         !Include Backspace
  1919.         Relocate_# = True
  1920.         CYCLE                 !Cycle to get key with ASK
  1921.       .
  1922.       IF Len#                 !    And Find The Record
  1923.         Relocate_# = True
  1924.         DO Find_Record
  1925.       ELSE
  1926.         Relocate_# = False
  1927.       .
  1928.       IF Relocate_# = False THEN BREAK.
  1929.     .
  1930. *StrLocate**********************************************************************
  1931.       @LocField = CLIP(Scr:Locator)         !    Update The Key Field
  1932. *PicLocate**********************************************************************
  1933.       @LocField = DEFORMAT(Scr:Locator)         !    Update The Key Field
  1934. *Selector***********************************************************************
  1935.       CLEAR(@Pre:Record)             !!Clear Any Stray Values
  1936.       @RestSelects                 !!Reset Selector Fields
  1937.       SET(@KeyName,@KeyName); ChkErr         !Set At First Selected Record
  1938.       LOOP UNTIL EOF(@FileName)             !Loop Until End Of File
  1939.     NEXT(@FileName); ChkErr             !  Read A Record
  1940.     @CheckSelect                 !  Check That It Is Selected
  1941.     DO Add_Table                 !  And Add To Memory Table
  1942.       .
  1943. *Filter*************************************************************************
  1944.       BUFFER(@Filename,0.25)             !Use 1/4Th Of Memory For Buffer
  1945.       SET(@FileName); ChkErr             !Read Data Record Sequence
  1946.       LOOP UNTIL EOF(@FileName)             !Loop Until End Of File
  1947.     NEXT(@FileName); ChkErr             !  Read A Record
  1948.     DO Add_Table                 !  Add It To Memory Table
  1949.       .
  1950.       FREE(@FileName)                 !Free Memory Used For Buffering
  1951.       DO Sort_Table                 !Sort Table Into Key Sequence
  1952.       Ptr = 1                     !Display From Top Of Tanle
  1953. *Validate***********************************************************************
  1954.     @AccessField = @Field             !Move Related Fields
  1955.     GET(@FileName,@AccessKey)         !Read The Record
  1956.     IF ERROR()                 !If No Record Is Found
  1957.       Mem:Message = 'Record not found!'     !  Move An Error Message
  1958.       BEEP                     !  Sound The Keyboard Alarm
  1959.       SELECT(?@Field)             !  And Stay On The Same Field
  1960.     .
  1961. *EnterTable*********************************************************************
  1962.     @AccessField = @Field             !Move Related Fields
  1963.     GET(@FileName,@AccessKey)         !Read The Record
  1964.     IF ERROR()                 !If No Record Is Found
  1965.       Action# = Action             !  Save Action
  1966.       Action = eView             !  Request Table Lookup
  1967.       @Lookup                 !  Call Lookup Procedure
  1968.       @Field = @AccessField             !  Move Lookup Field
  1969.       DISPLAY(?@Field)             !  And Display It
  1970.       IF Action                 !! No Selection Was Made
  1971.         SELECT(?@Field)             !!
  1972.         Action = Action#             !!
  1973.         BREAK                 !!
  1974.       .                     !!
  1975.       Action = Action#             !  Restore Action
  1976.     .
  1977. *AutoTable**********************************************************************
  1978.     @AccessField = @Field             !Move Related Fields
  1979.     GET(@FileName,@AccessKey)         !Read The Record
  1980.     Action# = Action             !Save Action
  1981.     Action = eView                 !Request Table Lookup
  1982.     @Lookup                     !Call Lookup Procedure
  1983.     @LookField = @AccessField         !Save Lookup Field
  1984.     @Field = @AccessField             !Move Lookup Field
  1985.     DISPLAY(?@Field)             !And Display It
  1986.     IF Action THEN SELECT(?@Field-1).     !No Selection Was Made
  1987.     Action = Action#             !Restore Action
  1988. *HotTable***********************************************************************
  1989.     IF KEYCODE() = @HotKey             !If Hot Key Pressed
  1990.       UPDATE                 !  Update All Fields
  1991.       @AccessField = @Field             !  Move Related Fields
  1992.       GET(@FileName,@AccessKey)         !  Read The Record
  1993.       Action# = Action             !  Save Action
  1994.       Action = eView             !  Request Table Lookup
  1995.       @Lookup                 !  Call Lookup Procedure
  1996.       @Field = @AccessField             !  Move Lookup Field
  1997.       DISPLAY(?@Field)             !  And Display It
  1998.       IF Action THEN SELECT(?@Field).     !  No Selection Was Made
  1999.       Action = Action#             !  Restore Action
  2000.     .
  2001. *NextForm***********************************************************************
  2002.     IF Action <> eDelete             !If This Is Not A Delete
  2003.       Action = eChange             !  Set Action To Change Mode
  2004.       @NextPage                 !  Call Next Form Procedure
  2005.       IF Action                 !  If Record Was Not Changed
  2006.         SELECT(?Last_Field - 1)         !    Select The Last Entry
  2007.         BREAK                 !    And Loop Again
  2008.     . .
  2009. *Pause**************************************************************************
  2010.       OF ?Pause_Field                 !On Pause Field
  2011.     IF KEYCODE() <> Enter_Key    |         !If Not Enter Key
  2012.     AND KEYCODE() <> Accept_Key         !And Not Ctrl-Enter Key
  2013.       BEEP                     !  Sound Keyboard Alarm
  2014.       SELECT(?Pause_Field)             !  And Stay On Pause Field
  2015.     .
  2016. *Lookups************************************************************************
  2017.     UPDATE                     !Update Record Keys
  2018.     IF @AccessField <> @Field
  2019.       @AccessField = @Field             !Move Related Key Fields
  2020.       GET(@FileName,@AccessKey)             !Read The Record
  2021.       IF ERROR()                 !!If Not Found
  2022.     CLEAR(@Pre:Record)             !!  Clear The Record
  2023. !!    SHOW(ROW(#ScrField),COL(#ScrField),'NF') !!  Show Short Message
  2024. !!    #ScrField = 'Not Found!'         !!  Show Long Message
  2025.     . .
  2026.     @ScrField = @LookupField             !!  Display Lookup Field
  2027. *LookupScroll*******************************************************************
  2028.     IF @AccessField <> @Field
  2029.       @AccessField = @Field             !Move Related Key Fields
  2030.       GET(@FileName,@AccessKey)             !Read The Record
  2031.       IF ERROR()                 !!If Not Found
  2032.     CLEAR(@Pre:Record)             !!  Clear The Record
  2033. !!    SHOW(ROW(@ScrField),COL(#ScrField),'NF') !!  Show Short Message
  2034. !!    #ScrField = 'Not Found!'         !!  Show Long Message
  2035.     . .
  2036.     @ScrField = @LookupField             !!  Display Lookup Field
  2037. *OpenFiles**********************************************************************
  2038.  ! DataFile_ = '@FileName'             !!Show Name Of File
  2039.  SHOW(25,1,CENTER('OPENING FILE: ' & '@FILENAME',80)) !DISPLAY FILE NAME
  2040.   OPEN(@FileName)                 !Open The File
  2041.   IF ERROR()                     !OPEN RETURNED AN ERROR
  2042.     CASE ERRORCODE()                 ! CHECK FOR SPECIFIC ERROR
  2043.     OF 46                     !  KEYS NEED TO BE REQUILT
  2044.       SETHUE(0,7)                 !  BLACK ON WHITE
  2045.       SHOW(25,1,CENTER('REBUILDING KEY FILES FOR @FILENAME',80)) !INDICATE MSG
  2046.       BUILD(@FILENAME)                 !  CALL THE BUILD PROCEDURE
  2047.       SETHUE(7,0)                 !  WHITE ON BLACK
  2048.       BLANK(25,1,1,80)                 !  BLANK THE MESSAGE
  2049.  
  2050.     @CREATEFILE                     !  IF NOT FOUND, THEN CREATE
  2051.      OF 51
  2052.       BLANK(25,1,1,80)                 !  BLANK THE MESSAGE
  2053.     ELSE                     ! ANY OTHER ERROR
  2054.       LOOP;STOP('@FILENAME: ' & ERROR()).     !  STOP EXECUTION
  2055.   . .
  2056.  
  2057. *CreateFile*********************************************************************
  2058.   OF 2
  2059. ! IF ERRORCODE() = 2                 !If Not Found, Then Create
  2060.     CREATE(@FileName)
  2061.     ChkErr                   !IS THIS MY ERROR ? DAVID
  2062. ! .
  2063. *SaveItems**********************************************************************
  2064.          GROUP,PRE(Sav)
  2065.            @BreakFields
  2066.            @SelectFields
  2067.          .
  2068. *SAVETOTALS*********************************************************************
  2069. TOT_GROUP    GROUP,PRE(TOT)             !TABLE TOTAL FIELDS
  2070.            @TOTALFIELDS
  2071.          .
  2072. *TOTALCALC**********************************************************************
  2073.   BUFFER(@FILENAME,.25)                 !USE 1/4TH OF MEMORY FOR BUFFER
  2074.   @TOTCLEAR                     !ZERO TOTALS
  2075.   SET(@FILENAME)                 !READ DATA RECORD SEQUENCE
  2076.   SETHUE(BACKHUE(ROW,COL),BACKHUE(ROW,COL))     !TURN OFF DISPAY
  2077.   LOOP UNTIL EOF(@FILENAME)             !LOOP UNTIL END OF FILE
  2078.     NEXT(@FILENAME)                 !  READ A RECORD
  2079.     DO SHOW_RECORD                 !  DO COMPUTEDS, CONDS, & LKUPS
  2080.     @TOTPLUS                     !  ADD IT TO TOTAL AMOUNT
  2081.   .
  2082.   SETHUE()                     !TURN OFF SETHUE
  2083.   FREE(@FILENAME)                 !FREE MEMORY USED FOR BUFFERING
  2084. *TOTALCALCSEL*******************************************************************
  2085.   SETHUE(BACKHUE(ROW,COL),BACKHUE(ROW,COL))     !TURN OFF DISPLAY
  2086.   DO SHOW_LINE                     !  CALC SCROLLING LINE FIELDS
  2087.   @TOTPLUS                     !  ADD TO TOTALS
  2088.   SETHUE()
  2089. *DOTOTALS***********************************************************************
  2090.       IF ACTN# THEN DO COMP_TOTALS.         !CALCULATE TABLE TOTALS
  2091. *COMPUTETOTS********************************************************************
  2092. COMP_TOTALS  ROUTINE                 !CALCULATE TOTAL FIELDS
  2093.   CASE ACTN#                     !CHECK FOR ADD,REV,DEL
  2094.   OF INS_KEY                     !ADD NEW AMOUNT TO TOTAL
  2095.     @TOTPLUS
  2096.   OF ENTER_KEY                     !REVISE TOTAL AMOUNT
  2097.     @TOTCHANGE
  2098.   .
  2099.   ACTN# = ''
  2100. *TOTCHECK***********************************************************************
  2101.       ACTN# = KEYCODE()             !SAVE ACTION FOR COMP_TOTALS
  2102.       @TOTSAVE
  2103. *TOTCLEAR***********************************************************************
  2104.   CLEAR(TOT_GROUP)                 !ZERO TOTALS
  2105.   @TOTCLEARIMPL                     !ZERO AVERAGE CALC IMPLICITS
  2106. *TOTESC*************************************************************************
  2107.         ACTN# = ''                 !RESET ACTN
  2108. *InitBreak**********************************************************************
  2109.     @SaveField = @Field                 !Save Break Field
  2110. *InitSelects********************************************************************
  2111.     @SaveField = @Field                 !Save Selector Field
  2112. *RestSelects********************************************************************
  2113.     @Field = @SaveField                 !Restore Selector Field
  2114. !*CheckBreak*********************************************************************
  2115. !     IF @Field <> @SaveField THEN BREAK.     !Break On New Group
  2116. *SortTable**********************************************************************
  2117.   SORT(Table,@Component)             !Sort Table Into Key Sequence
  2118. *CheckSelect********************************************************************
  2119.     IF @Field <> @SaveField THEN BREAK.     !Break On End Of Selection
  2120. *CheckAdd***********************************************************************
  2121.   IF @Field <> @SaveField THEN EXIT.         !Exit On End Of Selection
  2122. *CheckHot***********************************************************************
  2123.       IF KEYCODE() = @HotKey             !On Hot Key
  2124.     @HotProc                 !  Call Hot Key Procedure
  2125.     SELECT(?)                 !  Do Same Field Again
  2126.     CYCLE                     !  And Loop Again
  2127.       .
  2128. *TableHot***********************************************************************
  2129.       IF KEYCODE() = @HotKey             !On Hot Key
  2130.     IF FIELD() = ?Point THEN DO Get_Record.     !  Read Record If Needed
  2131.     @HotProc                 !  Call Hot Key Procedure
  2132.     DO Same_Page                 !  Reset To Same Page
  2133.     DO Show_Table                 !  Display A Page Of Records
  2134.     CYCLE                     !  And Loop Again
  2135.       .
  2136. *BuildTable*********************************************************************
  2137.   Ptr = 1                     !Start At Table Entry
  2138.   Ndx = 1                     !Put Selector Bar On Top Item
  2139.   DO Build_Table                 !Build Memory Table Ok Keys
  2140. *AutoNumKey*********************************************************************
  2141.       DO GET_RECORD                 !READ CURRENT SCREEN RECORD
  2142.       SAVPTR# = POINTER(@FILENAME)         ! AND SAVE POSITION
  2143.       SET(@KEYNAME);ChkErr             !SET TO HIGHEST KEY VALUE
  2144.       PREVIOUS(@FILENAME)             !READ LAST KEY RECORD
  2145.       IF NOT ERROR()             !!
  2146.         KEYFIELD# = @INCFIELD + 1         !!INCREMENT FIELD
  2147.       ELSE
  2148.         KEYFIELD# = 1             !!INCREMENT FIELD
  2149.       .
  2150.       CLEAR(@PRE:RECORD)             !CLEAR LAST KEY RECORD
  2151.       @INCFIELD = KEYFIELD#             !LOAD KEY FIELD
  2152.  
  2153. *AUTONUMESC*********************************************************************
  2154.       IF ACTION                 !FORM WAS NOT COMPLETED
  2155.         @TOTESC                 !CLEAR TOTAL FIELD CALCULATIONS
  2156.         POINTER# = SAVPTR#             !SET POINTER TO PROPER REC
  2157.         GET(@FILENAME,POINTER#)         !READ RECORD
  2158.         SET(@KEYNAME,@KEYNAME)         !POSITION FILE
  2159.         SKIP(@FILENAME,-1)             !BACK UP ONE
  2160.         DO SHOW_TABLE             !RE-DISPLAY PAGE
  2161.       .
  2162. *AutoNumSel*********************************************************************
  2163.       GET(Table,RECORDS(Table))         !Read Highest Key Value
  2164.       IF ERROR() THEN CLEAR(Table).         !Zero Fields If Empty Table
  2165.       @RESTSELECTS                 !LOAD PRIOR KEY FIELDS
  2166.       @INCFIELD = @TABLEFIELD + 1         !LOAD INCREMENT FIELD
  2167.  
  2168. *Conditional********************************************************************
  2169.       IF @IfCond                 !Evaluate Condition
  2170.     @IfCondTrue                 !  Condition Is True
  2171.       ELSE                     !Otherwise
  2172.     @IfCondFalse                 !  Condition Is False
  2173.       .
  2174. *RUNMAP*************************************************************************
  2175.            PROC(G_RUNPROC)             !GLOBAL MODULE RUN PROCEDURE
  2176. *RUNPROC************************************************************************
  2177. G_RUNPROC    PROCEDURE(DOSPROG)             !GLOBAL RUN PROCEDURE
  2178. DOSPROG         STRING(12)                 !PROGRAM TO RUN
  2179. SCREEN         SCREEN    WINDOW(25,80),HUE(7,0,0). !SAVE WINDOW
  2180.  
  2181.   CODE
  2182.   OPEN(SCREEN)                     !SAVE CURRENT SCREEN
  2183.   SETCURSOR(25,1)                 !POSITION CURSOR AT BOTTOM
  2184.   RUN(DOSPROG)                     !RUN DOS PROGRAM
  2185.   CLOSE(SCREEN)                     !RESTORE SCREEN
  2186.   RETURN                     !EXIT BACK TO CALLING MENU
  2187. *RUNCODE************************************************************************
  2188.       G_RUNPROC('@RUNDESC')             !RUN DOS PROGRAM
  2189. *FIRSTBREAK*********************************************************************
  2190.   BRK_FLAG# = 0                     !CLEAR BREAK LEVEL FLAG
  2191.   DO PRT_BRK_HDRS                 !PRINT GROUP HEADER(S)
  2192. *CHECKBREAK*********************************************************************
  2193.     IF NOT DONE# THEN DO CHECK_BREAK.         !  CHECK FOR GROUP BREAK
  2194. *LASTBREAK**********************************************************************
  2195.   BRK_FLAG# = 0                     !CLEAR BREAK LEVEL FLAG
  2196.   DO PRT_BRK_FTRS                 !PRINT GROUP FOOTER(S)
  2197. *BREAKRTN***********************************************************************
  2198. CHECK_BREAK  ROUTINE                 !CHECK FOR GROUP BREAK
  2199.   @COMPAREBREAK                     !GENERATE IF STATEMENTS
  2200.  
  2201. PRT_BRK_HDRS ROUTINE                 !DO GROUP HEADERS
  2202.   @BREAKHEADER                     !PRINT HEADERS
  2203.   @INITBREAK                     !INITIALIZE BREAK FIELDS
  2204.  
  2205. PRT_BRK_FTRS ROUTINE                 !DO GROUP FOOTERS
  2206.   GET(@FILENAME,LAST_REC#)             !REREAD PREVIOUS RECORD
  2207.   @BREAKFOOTER                     !PRINT FOOTERS
  2208.   SKIP(@FILENAME,-1)                 !BACKUP ONE RECORD
  2209.   NEXT(@FILENAME)                 !AND REREAD IT
  2210. *COMPAREBREAK*******************************************************************
  2211.   IF @FIELD <> @SAVEFIELD             !BREAK ON NEW GROUP
  2212.     BRK_FLAG# = @BRKNUM                 !SET BREAK LEVEL
  2213.     DO PRT_BRK_FTRS                 !PRINT FOOTERS FOR THIS LEVEL
  2214.     DO PRT_BRK_HDRS                 !PRINT HEADERS FOR THIS LEVEL
  2215.     EXIT                     !RETURN TO REPORT
  2216.   .
  2217. *BREAKHEADER********************************************************************
  2218.   IF BRK_FLAG# <= @BRKNUM             !CHECK BREAK LEVEL
  2219.     @INITGROUP                     ! INIT GROUP VARIABLES
  2220.     @GRPHEADER                     ! DO HEADER COMPUTES
  2221.     PRINT(GRP_HEAD@BRKNUM)             ! PRINT GROUP HEADER
  2222.     @PRINTMEMO                     ! PRINT ANY MEMO FIELD
  2223.     DO CHECK_PAGE                 ! DO PAGE BREAK IF NEEDED
  2224.   .
  2225. *BREAKFOOTER********************************************************************
  2226.   IF BRK_FLAG# <= @BRKNUM             !CHECK BREAK LEVEL
  2227.     @GRPFOOTER                     ! DO FOOTER COMPUTES
  2228.     PRINT(GRP_FOOT@BRKNUM)             ! PRINT GROUP FOOTER
  2229.     @PRINTMEMO                     ! PRINT ANY MEMO FIELD
  2230.     DO CHECK_PAGE                 ! DO PAGE BREAK IF NEEDED
  2231.     @PAGEEJECT                     ! GO TO NEW PAGE
  2232.   .
  2233. *PAGEEJECT**********************************************************************
  2234.     MEM:LINE = 0                 !  SET FOR CALL TO CHECK_PAGE
  2235.     DO CHECK_PAGE                 !  INITIALIZE PAGE VARIABLES
  2236.     IF NOT DONE#                 !  MORE ITEMS TO PRINT
  2237.       PRINT(PAGE_FOOT)                 !  PRINT PAGE FOOTER
  2238.       PRINT(PAGE_HEAD)                 !  PRINT PAGE HEADER
  2239.     .
  2240. ********************************************************************************
  2241.