*SAM002-Name & number table maint.(NON-EXECUTABLE ANNOTATED COPY)******************************** *DATE OF LAST UPDATE 05/10/83 * *REVISION NUMBER 001.00 * * THIS PROGRAM PLACED INTO PUBLIC DOMAIN BY * * DOUGLAS G. COUSE, ATLANTA, GA. 5/20/83 * * COPYING FOR NON-COMMERCIAL OR EDUCATIONAL * * PURPOSES ALLOWED, PROVIDED THIS NOTICE IS * * NOT REMOVED. COMMERCIAL RESALE IS PROHIBITED. * * * * This command file provides for the maintenance of name data. * * * * NOTES:-------------------------------------------------------- * * 1. This database is indexed on the field named "KEY" and * * has one index file. * * 2. The maximum number of records which this file may have * * is 99 due to the size of the numeric field NUMBER. * * 3. The maximum number of records which can be displayed or * * updated at any one time are limited to 60 records. * * 4. All explanatory comments are enclosed in boxes, indented * * and immediately precede the section of programming code * * to which they refer. * *-----------------------------------------------------------------------------------------------* * DATABASE & OTHER FILE UTILIZATION STATISTICS * * * * Database file: SAMFILE.DBF, Record length 14 characters * * Index file: SAMAKEY.NDX m * Memory file: NONE * * Other files: SAMSCR1.CMD This is a command file which contains the screen image used * * by this program and is called from the program initialization* * section P-001. * * * * SAM001.CMD This is the ENTRY PROGRAM command file and may call the * * the MAINTENANCE program into execution at the user's request.* * * * SAMMENU.CMD This is the MENU PROGRAM command file and functions as the * * the PRIMARY calling program which executes this program . * * * * Database File Structure:_______________________________________________________________ * * | | | | | | Memory | | * * | | | | | | Variable | | * * |Field #| Field Name |Type|Size|Decimal| Complement |Description if needed | * * |-------|------------|----|----|-------|------------|---------------------------------| * * | 1 | NUMBER | N | 2 | 0 | M:NUMBER | Numeric field converted to KEY | * * | | | | | | | | * * | 2 | NAME | C | 10 | | M:NAME | | * * | | | | | | | | * * | 3 | KEY | C | 2 | | M:KEY | Index file key field | * * --------------------------------------------------------------------------------------- * * * * NON-COMPLEMENTARY MEMORY VARIABLE UTILIZATION STATISTICS * * * * Variables Used:_____________________________________________________________________ * * | | Memory | | | | * * | | Variable | | | | * * | No.| Name |Type|Size| Description | * * |----|------------|----|----|------------------------------------------------------| * * | | | | | | * * | 1 | PROGRAM | C | 6 | This variable is initialized with the literal value | * * | | | | | "MAINT." for use by the screen display file SAMSCR1. | * * | | | | | | * * | 2 | LINE | N | 2 | This variable is an arithmetic accummulator used for | * * | | | | | dynamic line cursor positioning and is incremented | * * | | | | | by a constant value of 1 and initialized with a | * * | | | | | value of 7. | * * | | | | | | * * | 3 | COL | N | 2 | This variable is an arithmetic accummulator used for | * * | | | | | dynamic column cursor positioning and is incremented | * * | | | | | by constant values of 4 and 13 depending on the field| * * | | | | | to be processed and is initialized with a value of 2.| * * | | | | | | * * | 4 | MORE | C | 1 | This variable is used to enter and exit a doloop. It | * * | | | | | is the primary doloop variable of this command file | * * | | | | | and uses the literal "T" to enter the doloop and the | * * | | | | | literal "F" to exit the doloop. This variable is | * * | | | | | associated with a doloop which contains the initial | * * | | | | | record selection and accessing logic. | * * | | | | | | * * | 5 | ALWAYS | C | 1 | This variable is used to execute a series of doloops | * * | | | | | it is the secondary doloop var.of this command file | * * | | | | | and uses the literals "A" thru "C" to enter and exit | * * | | | | | the record display & record update doloops and then | * * | | | | | exit the program. | * * | | | | | | * * | | | | | | * * | 6 | RECNO | N | 2 | This variable is used to establish the starting point| * * | | | | | for display and updating of record data and provides | * * | | | | | the basis for determining the maximum number of rec- | * * | | | | | ords which can be displayed or updated. | * * | | | | | | * * | 7 | MAXIMUM | N | 2 | This variable is the sum of the value of RECNO and | * * | | | | | and a numeric constant of 59. It is the maximum # of| * * | | | | | records which can be displayed or updated at one time| * * ------------------------------------------------------------------------------------ * * * * MESSAGE UTILIZATION STATISTICS * * ____________________________________________________________________________________ * * | | | * * | TYPE | MESSAGE CONTENTS | * * |--------|-------------------------------------------------------------------------| * * | | | * * | PROMPT | Enter starting record ##, or strike to EXIT | * * | | | * * | ERROR | data NOT on file, strike any key to continue........... | * * | | | * * ------------------------------------------------------------------------------------ * ************************************************************************************************* ************************************************************************************************** *NOTE----any comment labelled (*P-) is a procedural section numbering reference * *that should be used in flowcharting and other program documentation. * ************************************************************************************************** *P-001-{START}. Program and screen initialization. ************************************************************************************************** * This section is a standardized program initialization section which: 1. disables screen dialog;* * 2. refreshes the screen; 3. refreshes memory; 4. closes any open database files; 5. provides a * * fresh work area for dbase; 6. initializes the program display variable used by SAMSCR1.CMD; * * 7. calls the screen image command file SAMSCR1.CMD for execution. * ************************************************************************************************** ERASE CLEAR USE SET COLON OFF SET TALK OFF SET ECHO OFF RELEASE STORE "MAINT." TO PROGRAM DO SAMSCR1 *P-001-{END}. ================================================================================= *P-005-{START}. Database file open & record access doloop initialization *and execution section. ************************************************************************************************** *database file open. * ************************************************************************************************** USE SAMFILE INDEX SAMAKEY ************************************************************************************************** *screen intensity is toggled off to insure that everything is displayed at high * *intensity * ************************************************************************************************** SET INTENSITY OFF ************************************************************************************************** *primary doloop initialization * ************************************************************************************************** STORE "T" TO MORE ************************************************************************************************** *execution of primary doloop * ************************************************************************************************** DO WHILE MORE = "T" ************************************************************************************************** *Initialization of starting record number variable. * *Display of record # entry PROMPT. * *Numeric conditional test to force termination of doloop where a record value is not entered. * ************************************************************************************************** STORE 00 TO RECNO @ 23,1 SAY "Enter starting record ##, or strike to EXIT " GET RECNO PICTURE '99' READ IF RECNO = 0 STORE "F" TO MORE LOOP ENDIF ************************************************************************************************** *pointer positioning and specific record accessing * ************************************************************************************************** GOTO TOP SET EXACT ON LOCATE FOR NUMBER = RECNO ************************************************************************************************** *conditional test to see if a specific record is on file * *if it is NOT on file a message is displayed and flow is returned to the beginning * *of the primary doloop for re-execution. * *The console toggling is done to inhibit the display of the auto message * *WAITING whenever the wait command is executed. The wait command is * *used so that the ERROR message will not be over written by the prompting * *message. * *Note the use of "IF EOF .OR. # = 0". This is a standardized end of file check * *used with indexed and non-indexed files. Use of this end of file check can prevent * *program execution error resulting from use of the wrong end of file check with * *the type of file accessing method being used. (indexed or non-indexed) * ************************************************************************************************** IF EOF .OR. # = 0 @ 22, 1 SAY "-" REMARK data NOT on file, strike any key to continue........... SET CONSOLE OFF WAIT SET CONSOLE ON SET EXACT OFF LOOP ENDIF SET EXACT OFF ************************************************************************************************** *secondary doloop variable initialization for stepwise execution of consecutive doloops based on * *the value of the doloop variable. * ************************************************************************************************** STORE "A" TO ALWAYS ************************************************************************************************** *establishment of the maximum number of records to be displayed and updated. * *Initialization of cursor positioning variables. * ************************************************************************************************** STORE RECNO + 59 TO MAXIMUM STORE 7 TO LINE STORE 2 TO COL *P-005-{END} ================================================================================= *P-010-{START}. NAME & NUMBER TABLE record display loop section. ************************************************************************************************** *execution of first consecutive secondary doloop * ************************************************************************************************** DO WHILE ALWAYS = "A" ************************************************************************************************** *NUMBER field display based on cursor positioning variable values. * *Columnar cursor positioning variable incrementing. * *NAME field display and advance to the next record in the database. * ************************************************************************************************** @ LINE, COL SAY NUMBER USING '99' STORE COL + 4 TO COL @ LINE, COL SAY NAME SKIP ************************************************************************************************** *Conditional test to determine if the last record in the database has been displayed or if the * *MAXIMUM number of records has been displayed. If so then the cursor positioning variables are * *re-initialized and the secondary doloop variable is set to "B" to exit the display doloop and * *execute the update doloop. * ************************************************************************************************** IF EOF .OR. # = 0 .OR. # > MAXIMUM STORE 7 TO LINE STORE 2 TO COL STORE "B" TO ALWAYS LOOP ENDIF ************************************************************************************************** *cursor positioning variable incrementing and conditional test to determine if * * 1. the COL variable is at the last field on the line. * * 2. the LINE variable is at the last available processing line on the screen * *if so then the variable or variables are re-initialized and the gets counter * *is re-initialized to prevent a TOO MANY GETS ERROR form occuring & to eliminate screen refresh * ************************************************************************************************** STORE COL + 13 TO COL IF COL = 70 STORE LINE + 1 TO LINE STORE 2 TO COL ENDIF LOOP ************************************************************************************************** *consecutive doloop terminiation point. * ************************************************************************************************** ENDDO *P-010-{END}. ================================================================================ *P-020-{START}. RECORD update doloop section. ************************************************************************************************** *pointer positioning and specific record accessing * ************************************************************************************************** GOTO TOP SET EXACT ON LOCATE FOR NUMBER = RECNO SET EXACT OFF ************************************************************************************************** *execution of second consecutive secondary doloop * ************************************************************************************************** DO WHILE ALWAYS = "B" ************************************************************************************************** *complementary variable initialization and display based on cursor positioning variable * *values. COL cursor positioning variable incrementing. * ************************************************************************************************** STORE NAME TO M:NAME @ LINE, COL SAY NUMBER USING '99' STORE COL + 4 TO COL ************************************************************************************************** *complementary variable updating based on cursor positioning variable values * ************************************************************************************************** @ LINE, COL GET M:NAME READ ************************************************************************************************** *Precision character string conditional test used to determine if the first 3 * *characters of the name variable are "END". This value would be entered by * *the user when maintenance is to be terminated without updating the entire screen * *If the test is true then the doloop variable will be set for "C" for program exit & * *program logic flow will be returned to the beginning of this doloop. * ************************************************************************************************** SET EXACT ON IF $(M:NAME,1,3) = "END" STORE "C" TO ALWAYS SET EXACT OFF LOOP ENDIF SET EXACT OFF ************************************************************************************************** *Record data replacement of old NAME field data with new data input by user * ************************************************************************************************** REPLACE NAME WITH M:NAME ************************************************************************************************** *cursor positioning variable incrementing and conditional test to determine if * * 1. the COL variable is at the last field on the line. * * 2. the LINE variable is at the last available processing line on the screen * *if so then the variable or variables are re-initialized and the gets counter * *is re-initialized to prevent a TOO MANY GETS ERROR form occuring & to elliminate screen refresh * ************************************************************************************************** STORE COL + 13 TO COL IF COL = 70 STORE LINE + 1 TO LINE STORE 2 TO COL ENDIF IF LINE > 21 STORE 7 TO LINE CLEAR GETS ENDIF ************************************************************************************************** *Advance to the next record in the database. * ************************************************************************************************** SKIP ************************************************************************************************** *Conditional test to determine if the last record in the database has been updated or if the * *MAXIMUM number of records have been updated. If so then the secondary doloop variable is set * *to "C" to terminate execution of the secondary doloop and exit the program. * ************************************************************************************************** IF EOF .OR. # = 0 .OR. # > MAXIMUM STORE "C" TO ALWAYS LOOP ENDIF LOOP ************************************************************************************************** *consecutive doloop terminiation point. * ************************************************************************************************** ENDDO STORE "T" TO MORE LOOP *P-020-{END} ================================================================================ *P-030-{START}. End of program execution and exit to menu ENDDO ************************************************************************************************** *close of the database * ************************************************************************************************** USE ************************************************************************************************** *program exit and housekeeping,ie. re-toggling of screen processing * *switches, clearing of memory, clearing of screen * ************************************************************************************************** SET INTENSITY ON SET COLON ON ERASE RELEASE ALL RETURN *P-030-{END}