home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol155 / sam002.doc < prev    next >
Encoding:
Text File  |  1984-04-29  |  23.9 KB  |  409 lines

  1. *SAM002-Name & number table maint.(NON-EXECUTABLE ANNOTATED COPY)********************************
  2. *DATE OF LAST UPDATE  05/10/83                                                                  *
  3. *REVISION NUMBER 001.00                                                                         *
  4. *                           THIS PROGRAM PLACED INTO PUBLIC DOMAIN BY                           *
  5. *                           DOUGLAS G. COUSE, ATLANTA, GA. 5/20/83                              *
  6. *                           COPYING FOR NON-COMMERCIAL OR EDUCATIONAL                           *
  7. *                           PURPOSES ALLOWED, PROVIDED THIS NOTICE IS                           *
  8. *                           NOT REMOVED. COMMERCIAL RESALE IS PROHIBITED.                       *
  9. *                                                *
  10. *    This command file provides for the maintenance of name data.                               *
  11. *                                                *
  12. *    NOTES:--------------------------------------------------------                *
  13. *          1. This database is indexed on the field named "KEY" and                *
  14. *          has one index file.                                *
  15. *       2. The maximum number of records which this file may have                *
  16. *          is 99 due to the size of the numeric field NUMBER.                *
  17. *       3. The maximum number of records which can be displayed or                  *
  18. *          updated at any one time are limited to 60 records.                    *
  19. *          4. All explanatory comments are enclosed in boxes, indented                          *
  20. *             and immediately precede the section of programming code                           *
  21. *             to which they refer.                                                              *
  22. *-----------------------------------------------------------------------------------------------*
  23. *     DATABASE & OTHER FILE UTILIZATION STATISTICS                            *
  24. *                                                *
  25. *    Database file: SAMFILE.DBF, Record length 14 characters                                 *
  26. *    Index file:    SAMAKEY.NDX                                m
  27. *    Memory file:   NONE                                    *
  28. *       Other files:   SAMSCR1.CMD This is a command file which contains the screen image used  *
  29. *                                  by this program and is called from the program initialization*
  30. *                                  section P-001.                                               *
  31. *                                                                                               *
  32. *                      SAM001.CMD  This is the ENTRY PROGRAM command file and may call the      *
  33. *                                  the MAINTENANCE program into execution at the user's request.*
  34. *                                                                                               *
  35. *                      SAMMENU.CMD This is the MENU PROGRAM command file and functions as the   *
  36. *                                  the PRIMARY calling program which executes this program .    *
  37. *                                                *
  38. *    Database File Structure:_______________________________________________________________ *
  39. *       |    |         |      |    |       | Memory     |                                 |    *
  40. *       |       |            |    |    |       | Variable   |                                 | *
  41. *    |Field #| Field Name |Type|Size|Decimal| Complement |Description if needed            | *
  42. *    |-------|------------|----|----|-------|------------|---------------------------------| *
  43. *    |   1   | NUMBER     | N  |  2 |   0   | M:NUMBER   | Numeric field converted to KEY  | *
  44. *       |       |            |    |    |       |            |                                 | *
  45. *       |   2   | NAME       | C  | 10 |       | M:NAME     |                                 | *
  46. *       |       |            |    |    |       |            |                                 | *
  47. *       |   3   | KEY        | C  |  2 |       | M:KEY      | Index file key field            | *
  48. *       --------------------------------------------------------------------------------------- *
  49. *                                                                                               *
  50. *    NON-COMPLEMENTARY MEMORY VARIABLE UTILIZATION STATISTICS                                *
  51. *                                                                                               *
  52. *    Variables Used:_____________________________________________________________________    *
  53. *    |    | Memory     |    |    |                                                      |    *
  54. *    |    | Variable   |    |    |                                                      |    *
  55. *     | No.| Name       |Type|Size|                     Description                      |    *
  56. *    |----|------------|----|----|------------------------------------------------------|    *
  57. *    |    |            |    |    |                                                      |    *
  58. *    |  1 | PROGRAM    | C  | 6  | This variable is initialized with the literal value  |    *
  59. *    |    |            |    |    | "MAINT." for use by the screen display file SAMSCR1. |    *
  60. *    |    |            |    |    |                                                      |    *
  61. *    |  2 | LINE       | N  | 2  | This variable is an arithmetic accummulator used for |    *
  62. *    |    |            |    |    | dynamic line cursor positioning and is incremented   |    *
  63. *    |    |            |    |    | by a constant value of 1 and initialized with a      |    *
  64. *    |    |            |    |    | value of 7.                                          |    *
  65. *    |    |            |    |    |                                                      |    *
  66. *    |  3 | COL        | N  | 2  | This variable is an arithmetic accummulator used for |    *
  67. *    |    |            |    |    | dynamic column cursor positioning and is incremented |    *
  68. *    |    |            |    |    | by constant values of 4 and 13 depending on the field|    *
  69. *    |    |            |    |    | to be processed and is initialized with a value of 2.|    *
  70. *    |    |            |    |    |                                                      |    *
  71. *    |  4 | MORE       | C  | 1  | This variable is used to enter and exit a doloop. It |    *
  72. *    |    |            |    |    | is the primary doloop variable of this command file  |    *
  73. *    |    |            |    |    | and uses the literal "T" to enter the doloop and the |    *
  74. *    |    |            |    |    | literal "F" to exit the doloop. This variable is     |    *
  75. *    |    |            |    |    | associated with a doloop which contains the initial  |    *
  76. *    |    |            |    |    | record selection and accessing logic.                |    *
  77. *    |    |            |    |    |                                                      |    *
  78. *    |  5 | ALWAYS     | C  | 1  | This variable is used to execute a series of doloops |    *
  79. *    |    |            |    |    | it is the secondary doloop var.of this command file  |    *
  80. *    |    |            |    |    | and uses the literals "A" thru "C" to enter and exit |    *
  81. *    |    |            |    |    | the record display & record update doloops and then  |    *
  82. *    |    |            |    |    | exit the program.                                    |    *
  83. *    |    |            |    |    |                                                      |    *
  84. *    |    |            |    |    |                                                      |    *
  85. *    |  6 | RECNO      | N  | 2  | This variable is used to establish the starting point|    *
  86. *    |    |            |    |    | for display and updating of record data and provides |    *
  87. *    |    |            |    |    | the basis for determining the maximum number of rec- |    *
  88. *    |    |            |    |    | ords which can be displayed or updated.              |    *
  89. *    |    |            |    |    |                                                      |    *
  90. *    |  7 | MAXIMUM    | N  | 2  | This variable is the sum of the value of RECNO and   |    *
  91. *    |    |            |    |    | and a numeric constant of 59.  It is the maximum # of|    *
  92. *       |    |            |    |    | records which can be displayed or updated at one time|    * 
  93. *       ------------------------------------------------------------------------------------    *
  94. *                                                                                               *
  95. *       MESSAGE UTILIZATION STATISTICS                                                          *
  96. *       ____________________________________________________________________________________    *
  97. *       |        |                                                                         |    *
  98. *       | TYPE   |  MESSAGE CONTENTS                                                       |    *
  99. *       |--------|-------------------------------------------------------------------------|    *
  100. *       |        |                                                                         |    *
  101. *       | PROMPT | Enter starting record ##, or strike <RETURN> to EXIT                    |    *
  102. *       |        |                                                                         |    *
  103. *       | ERROR  | data NOT on file, strike any key to continue...........                 |    *
  104. *       |        |                                                                         |    *
  105. *       ------------------------------------------------------------------------------------    *
  106. *************************************************************************************************
  107.  
  108.             **************************************************************************************************
  109.                         *NOTE----any comment labelled (*P-) is a procedural section numbering reference                  *
  110.             *that should be used in flowcharting and other program documentation.                            *
  111.             **************************************************************************************************
  112.  
  113.  
  114. *P-001-{START}. Program and screen initialization.
  115.  
  116.             **************************************************************************************************
  117.             * This section is a standardized program initialization section which: 1. disables screen dialog;*
  118.             * 2. refreshes the screen; 3. refreshes memory; 4. closes any open database files; 5. provides a * 
  119.             * fresh work area for dbase; 6. initializes the program display variable used by SAMSCR1.CMD;    *
  120.             * 7. calls the screen image command file SAMSCR1.CMD for execution.                              *
  121.             **************************************************************************************************
  122.  
  123. ERASE
  124. CLEAR
  125. USE
  126. SET COLON OFF
  127. SET TALK OFF
  128. SET ECHO OFF
  129. RELEASE
  130. STORE "MAINT." TO PROGRAM
  131. DO SAMSCR1
  132. *P-001-{END}.
  133.  
  134. =================================================================================
  135.  
  136. *P-005-{START}. Database file open & record access doloop initialization
  137. *and execution section.
  138.  
  139.             **************************************************************************************************
  140.             *database file open.                                                                             *  
  141.             **************************************************************************************************
  142.  
  143. USE SAMFILE INDEX SAMAKEY
  144.  
  145.             **************************************************************************************************
  146.             *screen intensity is toggled off to insure that everything is displayed at high                  *
  147.             *intensity                                                                                       *
  148.             **************************************************************************************************
  149.    
  150. SET INTENSITY OFF
  151.  
  152.             **************************************************************************************************
  153.             *primary doloop initialization                                                                   *     
  154.             **************************************************************************************************
  155.  
  156. STORE "T" TO MORE
  157.  
  158.             **************************************************************************************************
  159.             *execution of primary doloop                                                                     *
  160.             **************************************************************************************************
  161.  
  162. DO WHILE MORE = "T"
  163.  
  164.             **************************************************************************************************
  165.             *Initialization of starting record number variable.                                              *  
  166.             *Display of record # entry PROMPT.                                                      *  
  167.             *Numeric conditional test to force termination of doloop where a record value is not entered.     *  
  168.                **************************************************************************************************
  169.  
  170. STORE 00 TO RECNO
  171. @ 23,1 SAY "Enter starting record ##, or strike <RETURN> to EXIT  " GET RECNO PICTURE '99' 
  172. READ
  173. IF RECNO = 0
  174.     STORE "F" TO MORE
  175.     LOOP
  176. ENDIF
  177.  
  178.             **************************************************************************************************
  179.             *pointer positioning and specific record accessing                                               *  
  180.             **************************************************************************************************
  181.  
  182. GOTO TOP
  183. SET EXACT ON
  184. LOCATE FOR NUMBER = RECNO
  185.  
  186.             **************************************************************************************************
  187.             *conditional test to see if a specific record is on file                                         *
  188.             *if it is NOT on file a message is displayed and flow is returned to the beginning               *
  189.             *of the primary doloop for re-execution.                                                         *               
  190.             *The console toggling is done to inhibit the display of the auto message                         *
  191.             *WAITING whenever the wait command is executed. The wait command is                              *
  192.             *used so that the ERROR message will not be over written by the prompting                        *
  193.             *message.                                                                                        *
  194.                         *Note the use of "IF EOF .OR. # = 0".  This is a standardized end of file check                  *
  195.             *used with indexed and non-indexed files.  Use of this end of file check can prevent             *
  196.             *program execution error resulting from use of the wrong end of file check with                  * 
  197.             *the type of file accessing method being used. (indexed or non-indexed)                          * 
  198.             **************************************************************************************************
  199.  
  200. IF EOF .OR. # = 0
  201.     @ 22, 1 SAY "-"
  202.     REMARK data NOT on file, strike any key to continue...........
  203.     SET CONSOLE OFF
  204.     WAIT
  205.     SET CONSOLE ON
  206.     SET EXACT OFF
  207.     LOOP
  208. ENDIF
  209. SET EXACT OFF
  210.  
  211.             **************************************************************************************************
  212.             *secondary doloop variable initialization for stepwise execution of consecutive doloops based on *     
  213.             *the value of the doloop variable.                                                               *
  214.             **************************************************************************************************
  215.  
  216. STORE "A" TO ALWAYS
  217.  
  218.             **************************************************************************************************
  219.             *establishment of the maximum number of records to be displayed and updated.                     *  
  220.             *Initialization of cursor positioning variables.                                                 *  
  221.                **************************************************************************************************
  222.  
  223. STORE RECNO + 59 TO MAXIMUM
  224. STORE 7 TO LINE
  225. STORE 2 TO COL
  226. *P-005-{END}
  227.  
  228. =================================================================================
  229.  
  230. *P-010-{START}. NAME & NUMBER TABLE record display loop section. 
  231.  
  232.             **************************************************************************************************
  233.             *execution of first consecutive secondary doloop                                                 *
  234.             **************************************************************************************************
  235.  
  236. DO WHILE ALWAYS = "A"
  237.  
  238.             **************************************************************************************************
  239.             *NUMBER field display based on cursor positioning variable values.                               *
  240.             *Columnar cursor positioning variable incrementing.                                              *
  241.             *NAME field display and advance to the next record in the database.                              *
  242.             **************************************************************************************************
  243.  
  244. @ LINE, COL SAY NUMBER USING '99'
  245. STORE COL + 4 TO COL
  246. @ LINE, COL SAY NAME
  247. SKIP
  248.  
  249.             **************************************************************************************************               
  250.             *Conditional test to determine if the last record in the database has been displayed or if the   *
  251.             *MAXIMUM number of records has been displayed. If so then the cursor positioning variables are   *
  252.             *re-initialized and the secondary doloop variable is set to "B" to exit the display doloop and   *
  253.             *execute the update doloop.                                                                      *
  254.             **************************************************************************************************
  255.  
  256. IF EOF .OR. # = 0 .OR. # > MAXIMUM
  257.     STORE 7 TO LINE
  258.     STORE 2 TO COL
  259.     STORE "B" TO ALWAYS
  260.     LOOP
  261. ENDIF
  262.  
  263.             **************************************************************************************************
  264.             *cursor positioning variable incrementing and conditional test to determine if                   *
  265.             *      1. the COL variable is at the last field on the line.                                     *
  266.             *      2. the LINE variable is at the last available processing line on the screen               *
  267.             *if so then the variable or variables are re-initialized and the gets counter                    *
  268.             *is re-initialized to prevent a TOO MANY GETS ERROR form occuring & to eliminate screen refresh  *
  269.             **************************************************************************************************
  270.  
  271. STORE COL + 13 TO COL
  272. IF COL = 70
  273.     STORE LINE + 1 TO LINE
  274.     STORE 2 TO COL
  275. ENDIF 
  276. LOOP 
  277.  
  278.             **************************************************************************************************
  279.             *consecutive doloop terminiation point.                                                          * 
  280.             **************************************************************************************************
  281.  
  282. ENDDO
  283. *P-010-{END}.
  284.  
  285. ================================================================================
  286.  
  287. *P-020-{START}.  RECORD update doloop section.
  288.  
  289.             **************************************************************************************************
  290.             *pointer positioning and specific record accessing                                               *  
  291.             **************************************************************************************************
  292.  
  293. GOTO TOP
  294. SET EXACT ON
  295. LOCATE FOR NUMBER = RECNO
  296. SET EXACT OFF
  297.  
  298.             **************************************************************************************************
  299.             *execution of second consecutive secondary doloop                                                *
  300.             **************************************************************************************************
  301.  
  302. DO WHILE ALWAYS = "B" 
  303.  
  304.             **************************************************************************************************
  305.             *complementary variable initialization and display based on cursor positioning variable          *
  306.             *values. COL cursor positioning variable incrementing.                                           *
  307.             **************************************************************************************************
  308.  
  309. STORE NAME         TO M:NAME
  310. @ LINE, COL SAY NUMBER USING '99'
  311. STORE COL + 4 TO COL
  312.  
  313.             **************************************************************************************************
  314.             *complementary variable updating based on cursor positioning variable values                     *
  315.             **************************************************************************************************
  316.  
  317. @ LINE, COL GET M:NAME
  318. READ
  319.  
  320.             **************************************************************************************************
  321.             *Precision character string conditional test used to determine if the first 3                    *
  322.             *characters of the name variable are "END".  This value would be entered by                      *
  323.             *the user when maintenance is to be terminated without updating the entire screen                *
  324.             *If the test is true then the doloop variable will be set for  "C" for program exit &            *
  325.             *program logic flow will be returned to the beginning of this doloop.                            *
  326.             **************************************************************************************************
  327.  
  328. SET EXACT ON
  329. IF $(M:NAME,1,3) = "END"
  330.     STORE "C" TO ALWAYS
  331.     SET EXACT OFF
  332.     LOOP
  333. ENDIF
  334. SET EXACT OFF
  335.  
  336.             **************************************************************************************************
  337.             *Record data replacement of old NAME field data with new data input by user                      * 
  338.             **************************************************************************************************
  339.  
  340. REPLACE NAME WITH M:NAME
  341.  
  342.             **************************************************************************************************
  343.             *cursor positioning variable incrementing and conditional test to determine if                   *
  344.             *      1. the COL variable is at the last field on the line.                                     *
  345.             *      2. the LINE variable is at the last available processing line on the screen               *
  346.             *if so then the variable or variables are re-initialized and the gets counter                    *
  347.             *is re-initialized to prevent a TOO MANY GETS ERROR form occuring & to elliminate screen refresh *
  348.             **************************************************************************************************
  349.  
  350. STORE COL + 13 TO COL
  351. IF COL = 70
  352.     STORE LINE + 1 TO LINE
  353.     STORE 2 TO COL
  354. ENDIF 
  355. IF LINE > 21
  356.     STORE 7 TO LINE
  357. CLEAR GETS
  358. ENDIF
  359.  
  360.             **************************************************************************************************
  361.             *Advance to the next record in the database.                                                     *
  362.             **************************************************************************************************
  363.  
  364. SKIP
  365.  
  366.             **************************************************************************************************               
  367.             *Conditional test to determine if the last record in the database has been updated or if the     *
  368.             *MAXIMUM number of records have been updated. If so then the secondary doloop variable is set    *
  369.             *to "C" to terminate execution of the secondary doloop and exit the program.                     *
  370.             **************************************************************************************************
  371.  
  372. IF EOF .OR. # = 0 .OR. # > MAXIMUM
  373.     STORE "C" TO ALWAYS
  374.     LOOP
  375. ENDIF
  376. LOOP
  377.  
  378.             **************************************************************************************************
  379.             *consecutive doloop terminiation point.                                                          * 
  380.             **************************************************************************************************
  381.  
  382. ENDDO
  383. STORE "T" TO MORE
  384. LOOP
  385. *P-020-{END}
  386.  
  387. ================================================================================
  388.  
  389. *P-030-{START}. End of program execution and exit to menu
  390. ENDDO
  391.  
  392.             **************************************************************************************************
  393.             *close of the database                                                                           *
  394.             **************************************************************************************************
  395.  
  396. USE
  397.  
  398.             **************************************************************************************************
  399.             *program exit and housekeeping,ie. re-toggling of screen processing                              *
  400.             *switches, clearing of memory, clearing of screen                                                *
  401.             **************************************************************************************************
  402.  
  403. SET INTENSITY ON
  404. SET COLON ON
  405. ERASE
  406. RELEASE ALL
  407. RETURN
  408. *P-030-{END} 
  409.