Application Logic

 

When an application uses the Grid Management Library (GML) to interface with a grid control, the GML must be set-up based on parameters provided by the application.

Prototype topic: GML concepts provides additional information Relating to the GML.

a: GML Init:

Following is the code sequence used to initialize the GML for the Attached file prototype program gml_af):

   

0150 REM +-------------------------------+

0160 REM ! CALL TO OBTAIN GML TEMPLATE !

0170 REM +-------------------------------+

0180 LET GML_QTY%=1

0190 CALL "GML::START"

   

0200 REM +---------------------------------+

0210 REM ! IDENTIFY GRID'S TO BE MANAGED !

0220 REM +---------------------------------+

0230 REM +--------------+

0240 REM ! GRID SET 1 !

0250 REM +--------------+

0260 LET GML_INIT.MAIN_ID%[1]=5001

0270 LET GML_INIT.COL_HEADER_ID%[1]=5002

0280 LET GML_INIT.ROW_HEADER_ID%[1]=0

0290 LET GML_INIT.SYSGUI%[1]=SYSGUI

0300 LET GML_INIT.CONTEXT%[1]=DEC(CTRL(SYSGUI))

0310 LET GML_INIT.LUM_QTY%=2

   

0320 REM +-----------------------------------+

0330 REM ! CALL GML INITIALIZATION PROGRAM !

0340 REM +-----------------------------------+

0350 CALL

"GML_I",SYSGUI,GML_INIT$,GML$,GML_GM$[ALL],GML_GC$[ALL],GML_GR$[A

0350:LL],GML_SET$

   

b: LUM Init:

The GML can be configured to associate a list type control, such as a List button or list edit, with a particular event that occurs on a specific column within a main grid cell.

This feature provides the capability to temporarily show, at the location of a main grid cell, a list type control to be used to look-up and select information from a list of choices presented within the control.

The GML administers the tasks associated with moving, sizing, showing, and hiding the look-up control. The portion of the GML that manages these tasks is referred to as the GML look-up manager (LUM).

In this prototype, when the grid focus (highlighted cell) is on a cell in the item id or description column, pressing f8 or right clicking on the cell will display a listedit control that can be used to select an item id from a list of selections.

The following code segment initializes the look-up manager:

 

0360 REM +--------------------------+

0370 REM ! SET-UP LOOK-UP MANAGER !

0380 REM +--------------------------+

0390 REM +-----------------------+

0400 REM ! OBTAIN LUM TEMPLATE !

0410 REM +-----------------------+

0420 CALL "GML::INIT_LUM_TPL"

0430 REM +-----------------------+

0440 REM ! LOOK-UP INFORMATION !

0450 REM +-----------------------+

0460 LET GML_LUM.LU_ID%[1]=124

0470 LET GML_LUM.SET%[1]=1

0480 LET GML_LUM.COL%[1]=3

0490 LET GML_LUM.LOC%[1]=0

0500 LET GML_LUM.SCOPE%[1]=2

0510 LET GML_LUM.LU_ID%[2]=124

0520 LET GML_LUM.SET%[2]=1

0530 LET GML_LUM.COL%[2]=4

0540 LET GML_LUM.LOC%[2]=-1

0550 LET GML_LUM.SCOPE%[2]=1    

c: Attached File Init:

A template named gml_rcd$ is used to interface between the application and the program (gml_f) that manages the reading of the data channel.

This template is obtained by using the GML attached file procedure attach_file. This procedure may be used at any time after the GML has been initialized.

In this prototype, the attached file configuration is set at mode 1, mode 2, or mode 3 by clicking on the appropriate radio button in the mode group box. When a change in mode occurs, the following code is used to set-up the selected attach file mode:

The GML template is prepared and the procedure detach_file is executed to reset all GML variable associated with the attached file feature.

   

7610 REM +------------------------+

7620 REM ! SET-UP: ATTACH FILE !

7630 REM +------------------------+

7640 LET GML.SET%=1

7650 CALL "GML::TPL_PREP"

7660 CALL "GML::DETACH_FILE"

   

The GML template is again prepared, and procedure attach_file is Executed to start the attached file initialization process.

   

7680 CALL "GML::TPL_PREP"

7690 CALL "GML::ATTACH_FILE"

After execution of the attached_file procedure, the gml_rcd$ template is returned to the prototype by program GML, at which time the file channel is assigned by the prototype to variable gml_rcd.flag%. In addition, the attached file mode is set, based on the contents of variable gml_rcd.key$.

If variable gml_rcd.key$ is null, then the attached file mode is 1 (the entire file) if variable gml_rcd.key$ contains key data, and variable gml_rcd.key$ does not contain an embedded $00$, then the key data is used as the start key.

The attached file mode is set a 2 (a portion of the file with the full scope undetermined).

When gml_rcd.key$ contains key data, and variable gml_rcd.key$ contains an embedded $00$, then the key data is used as the start key, and end key. The attached file mode is set a 3 (a portion of the file with the scope determined by the start and end key).

The following code assigns the data channel and sets the attached file mode by assigning the appropriate data to variable gml_rcd.key$.

7710 LET GML_RCD.FLAG%=F_DATA_SOURCE%

7720 SWITCH ATTACH_MODE%

7730 CASE 1

7740 LET GML_RCD.KEY$=""

7750 BREAK

7760 CASE 2

7770 LET GML_RCD.KEY$=KEY_START$

7780 BREAK

7790 CASE 3

7800 LET GML_RCD.KEY$=KEY_START$+$00$+KEY_END$

7810 BREAK

7820 SWEND

 

The attached file configuration is then initialized in the following line of code:

   

7830 CALL "GML_F::INIT",GML$,GML_GRL$,GML_RCD$

After attached file initialization, program control is Transferred to subroutine gml_f to read the first group of records that will be displayed on the grid.

   

7950 GOSUB GML_F

7960 RETURN

   

d: Read Cycle:

There are four ways to move through (read) the attached file:

  • By clicking on one of the two visible vertical scroll bars

  • Using the keyboard page up/down keys

  • Using the keyboard arrow up/down keys

  • Selecting previous page or next page from the go to menu bar.

It is important to note that the scrolls bars on the right side of the Grid are not part of the grid, but controls that have been sized and positioned on the grid by program gml_f.

Each time the attached file is initialized, three scrollbars are created.

Depending on the attached file mode, two of the three scroll bars are made visible by program gml_f.

   

e: Events:

When the GML was initialized (see GML init), the id of the main Grid control (5001) was assigned to variable gml.gr_id%[1]. Accordingly, when the attached file was initialized (see attached file_init), three vertical scroll bars were created. The ids of these controls are equal to the main grid control id -1, main grid control +3, and the main grid control +4.

In the following code segment, which is part of the event queue decoding logic, an event on a scroll bar that is part of the attached file configuration is routed to subroutine gml_f for processing.

   

2580 REM +---------------------------------+

2590 REM ! SCROLL BAR CONTROL MOVED       !

2600 REM ! (GOSUB TO READ ATTACHED FILE) !

2610 REM +---------------------------------+

2620 CASE ASC("p")

2630 IF E.ID%=GML.GR_ID%[1]-1 OR GML.GR_ID%[1]+3 OR GML_GR_ID%[1]+4

THEN GO

2630:SUB GML_F

2640 BREAK

   

The following code segment is part of subroutine gml_m. When a grid event is caused by a keyboard arrow up/down or page up/down key press, the event is routed to subroutine gml_f for processing.

   

5430 REM +------------------------+

5440 REM ! GRID EVENT:          !

5450 REM ! HIT TOP /BOTTOM       !

5460 REM ! GML.NOTIFY%= 10 & 11 !

5470 REM +------------------------+

5480 CASE 10

5490 CASE 11; IF GML.SET%=1 THEN GOSUB GML_F

5500 BREAK

   

When a previous page or next page selection occurs from the go to menu bar, the following code segment, which is part of the event queue decoding logic, transfers program control to the gml_f subroutine after assigning the appropriate value to the gml_rcd.flag% variable.

 

When program gml_f is called by subroutine gml_f, the Gml_rcd.flag% variable is interpreted by program gml_f as if a page up or page down event has occurred from the keyboard.

   

1760 REM +------------------+

1770 REM ! MENU SELECTION !

1780 REM +------------------+

1790 CASE ASC("C")

.

.

1870 REM +-----------------+

1880 REM ! PREVIOUS PAGE !

1890 REM +-----------------+

1900 IF E.ID%=1503 THEN LET GML_RCD.FLAG%=21; GOSUB GML_F; BREAK

1910 REM +-------------+

1920 REM ! NEXT PAGE !

1930 REM +-------------+

1940 IF E.ID%=1504 THEN LET GML_RCD.FLAG%=22; GOSUB GML_F; BREAK

   

f: Call To GML_F:

Subroutine gml_f calls program gml_f to perform the next read of the attached file.

The quantity of records to read (referred to as the read cycle) and the direction of the reading of the file are based on the type of event that has caused the transfer of program control to this subroutine.

9000 REM 9000

9010 REM +--------------------------+

9020 REM ! ROUTINE: GML_F         !

9030 REM ! READ FILE, UPDATE GRID !

9040 REM +--------------------------+

9050 GML_F:

9060 REM +----------------------+

9070 REM ! SET CURSOR TO WAIT !

9080 REM ! & UPDATE STATBAR    !

9090 REM +----------------------+

9100 PRINT

(SYSGUI)'CONTEXT'(0),'FOCUS'(0),'SETCURSOR'(32514),'TITLE'(120,S

9100:TATUS$)

9110 LET STATUS$=""

   

9120 REM +--------------------------+

9130 REM ! CALL TO PROGRAM: GML_F !

9140 REM ! (ATTACHED FILE MANAGER) !

9150 REM +--------------------------+

9160 CALL_GML_F:

9170 CALL

"GML_F",E$,NOTICE$,GML_TPL$,GML$,GML_GM$[ALL],GML_GC$[ALL],GML_GR

9170:$[ALL],GML_GRL$,GML_RCD$,GML_DATA$

   

g: Read Status:

After calling program gml_f, the status of variable gml.flag% is checked.

If the value is negative, an error has occurred, and a message is displayed by transferring program control to subroutine msgbox. The subroutine then exits after setting the cursor to normal.

If no error has occurred, the value in variable gml_rcd.flag% is checked. If the value is less than 1, then the read cycle has ended and the subroutine exists after setting the cursor to normal.

   

9180 REM +---------------------+

9190 REM ! CHECK READ STATUS !

9200 REM +---------------------+

9210 IF GML.FLAG%<0 THEN LET MSG$="Attach File Error:

"+CHR(10)+"Error: "+

9210:STR(GML.FLAG%)+CHR(10)+GML_RCD.KEY$; LET MSG%=0+32+0; GOSUB

MSGBOX; GO

9210:TO CYCLE_END

9220 IF INT(GML_RCD.ROW_N%,ERR=CYCLE_END)<1 THEN GOTO CYCLE_END

   

h: Last Record Flag:

If the attached file mode is 2 and the value in gml_rcd.key$ indicates that it is not equal to the current order #, the value in ml_rcd.flag% is set to 1. This flag is used to indicate to program gml_f that the last record to be read has occurred. Program gml_f is then called and the read cycle is terminated when program gml_f exits with a gml_rcd.flag% value of 0.

9230 REM +-------------------------------+

9240 REM ! IF ATTACHED FILE MODE = 2    !

9250 REM ! & 0RD# NOT EQUAL TO CURRENT !

9260 REM ! ORD#, SET GML_RCD.FLAG%      !

9270 REM ! TO 1 (LAST RECORD FLAG)      !

9280 REM +-------------------------------+

9290 IF ATTACH_MODE%=2 THEN IF POS(KEY_START$(1,8)=GML_RCD.KEY$)<>1

THEN LE

9290:T GML_RCD.FLAG%=1; GOTO CALL_GML_F

   

i:   Data Substitution:

Changes to line items are stored in the o_line.tmp file, with the type of change stored in the up_log.tmp file. Each time program gml_f performs a read, the key and record data for the latest read are placed in variable gml_rcd.key$ and gml_data$.

The next section of code determines if changes exist, and if so, uses the data from the o_line.tmp file as the data to be formatted and displayed in the grid in place of the data obtained from the o_line file during the reading of the file by program gml_f.

   

9300 REM +------------------------------+

9310 REM ! CHECK FOR KEY IN TEMP FILE !

9320 REM +------------------------------+

9330 LET UP_LOG.ACTION$=" "

9340 READ RECORD(F_UP_LOG%,KEY=GML_RCD.KEY$,DOM=9410,END=9410)UP_LOG$

9350 READ

RECORD(F_O_LINE_TMP%,KEY=GML_RCD.KEY$,DOM=9410,END=9410)O_LINE$

9360 GOTO 9460

9370 REM +-------------------------+

9380 REM ! COPY RECORD DATA INTO !

9390 REM ! O_LINE TEMPLATE        !

9400 REM +-------------------------+

9410 LET O_LINE$=GML_RCD.DATA$

   

j: Template Prep:

Once the data (from either the o_line.tmp file or o_line file) has been placed into the o_line template, the GML template is prepared by calling program gml.

At this point, the colors to be displayed in the row of the grid are determined by switching on the value in variable p_log.action$.

The GML template is then updated with the template colors by using function fncolors$.

9420 REM +------------------------------+

9430 REM ! BASED ON LINE ITEM STATUS, !

9440 REM ! PREPARE GML TEMPLATE        !

9450 REM +------------------------------+

9460 CALL "GML::TPL_PREP"

9470 SWITCH ASC(UP_LOG.ACTION$)

   

9480 REM +--------------+

9490 REM ! NO CHANGES !

9500 REM +--------------+

9510 CASE ASC(" ")

9520 LET T_COLOR$=GML.BLACK$,B_COLOR$=GML.WHITE$

9530 BREAK

   

9540 REM +----------------------------+

9550 REM ! LINE ITEM HAS BEEN ADDED !

9560 REM +----------------------------+

9570 CASE ASC("A")

9580 LET T_COLOR$=GML.BLACK$,B_COLOR$=GML.GREEN$

9590 BREAK

   

9600 REM +------------------------------+

9610 REM ! LINE ITEM HAS BEEN CHANGED !

9620 REM +------------------------------+

9630 CASE ASC("C")

9640 LET T_COLOR$=GML.BLACK$,B_COLOR$=GML.CYAN$

9650 BREAK

   

9660 REM +------------------------------------------+

9670 REM ! LINE ITEM HAS BEEN MARKED FOR DELETION !

9680 REM +------------------------------------------+

9690 CASE ASC("D")

9700 LET T_COLOR$=GML.BLACK$,B_COLOR$=GML.LTGRAY$

9710 BREAK

   

9720 SWEND

9730 REM +-------------------------------------------+

9740 REM ! UPDATE TEMPLATE WITH APPROPRIATE COLORS !

9750 REM +-------------------------------------------+

9760 LET NULL$=FNCOLORS$(T_COLOR$,B_COLOR$)

   

9770 REM +----------------------------------------------+

9780 REM ! LOAD GRID ROW NUMBER INTO GML_TPL TEMPLATE !

9790 REM +----------------------------------------------+

9800 LET GML_TPL.ROW_N%=GML_RCD.ROW_N%

   

k: Data Formatting:

Data formatting is the next step in the read cycle, which occurs in subroutine data_prep.

The data_prep subroutine prepares the data for each column in the grid. In some cases the data is placed directly into the gml_tpl.col[c]$ template variable (columns 1, 5 & 8).

In other cases (columns 2, 3, 4, 6, & 7) additional treatment is required.

9810 REM +-------------+

9820 REM ! GOSUB FOR !

9830 REM ! DATA PREP !

9840 REM +-------------+

9850 GOSUB DATA_PREP

.

.

.

9970 REM +-------------------------+

9980 REM ! ROUTINE: DATA_PREP    !

9990 REM ! PREPARE / FORMAT DATA !

10000 REM ! AND LOAD GML TEMPLATE !

10010 REM +-------------------------+

10020 DATA_PREP:

   

10030 REM +---------------------------+

10040 REM ! COLUMN 1 DATA:          !

10050 REM ! FORMATTING NOT REQUIRED !

10060 REM +---------------------------+

10070 LET GML_TPL.COL$[1]=O_LINE.ORDER_NUM$

   

10080 REM +-------------------------------------+

10090 REM ! FORMAT COLUMN 2 AND COLUMN 3 DATA !

10100 REM +-------------------------------------+

10110 LET GML_TPL.COL$[2]=STR(NUM(O_LINE.LINE_NUM$):"0000")

10120 LET GML_TPL.COL$[3]=STR(NUM(O_LINE.ITEM_NUM$):"00")

   

10130 REM +---------------------------+

10140 REM ! COLUMN 4 DATA:          !

10150 REM ! OBTAIN ITEM DESCRIPTION !

10160 REM ! FROM ITEM FILE          !

10170 REM +---------------------------+

10180 READ RECORD(F_ITEM%,KEY=O_LINE.ITEM_NUM$)ITEM$

10190 LET GML_TPL.COL$[4]=CVS(ITEM.DESCRIPTION$,3)

   

10200 REM +---------------------------+

10210 REM ! COLUMN 5 DATA:          !

10220 REM ! FORMATTING NOT REQUIRED !

10230 REM +---------------------------+

10240 LET GML_TPL.COL$[5]=STR(O_LINE.QTY_ORDERED)

   

10250 REM +------------------------+

10260 REM ! FORMAT COLUMN 6 DATA !

10270 REM +------------------------+

10280 LET GML_TPL.COL$[6]=STR(O_LINE.PRICE:"##,##0.00")

   

10290 REM +----------------------------+

10300 REM ! COLUMN 7 DATA:            !

10310 REM ! CALCULATE, BASED ON       !

10320 REM ! COLUMN 5 & COLUMN 6 DATA !

10330 REM +----------------------------+

10340 LET

GML_TPL.COL$[7]=STR(O_LINE.QTY_ORDERED*O_LINE.PRICE:"##,##0.00")

   

10350 REM +---------------------------+

10360 REM ! COLUMN 8 DATA:          !

10370 REM ! FORMATTING NOT REQUIRED !

10380 REM +---------------------------+

10390 LET GML_TPL.COL$[8]=STR(O_LINE.LINE_WEIGHT)

10400 RETURN

    

l:   Next Read:

After preparing and placing the data into template gml_tpl$, subroutine gml_f branches to the call to program gml_f.

Program gml_f displays the formatted data and performs the next read as required.

9860 REM +-------------------+

9870 REM ! GET NEXT RECORD !

9880 REM +-------------------+

9890 GOTO CALL_GML_F

   

n: Cycle End:

When the read cycle has concluded, the cursor is set to normal, and subroutine gml_f terminates.

   

9900 REM +-------------------------------------+

9910 REM ! CHANGE TO NORMAL CURSOR, CLEAR     !

9920 REM ! STATBAR & RETURN TO EVENT HANDLER !

9930 REM +-------------------------------------+

9940 CYCLE_END:

9950 PRINT (SYSGUI)'SETCURSOR'(32512),'TITLE'(120,"")

9960 RETURN

   

o: Storing Changes:

Changes to line item information are made by editing a main grid cell. These changes are validated, then the updated information is stored in the o_line.tmp file.

The subroutine store_changes is used to administer the storing and updating of changes, in the following manner:

The information in template gml_tpl$.col$[1] and gml_tpl.col$[2] are used to construct the file key:

11150 REM +---------------------+

11160 REM ! UPDATE TEMP FILES !

11170 REM ! WITH CHANGED INFO !

11180 REM +---------------------+

11190 STORE_CHANGES:

11200 LET

O_LINE_KEY$=STR(NUM(GML_TPL.COL$[1]):"00000000")+STR(NUM(GML_TPL.C

11200:OL$[2]):"00000000")

   

The o_line.tmp file is checked first to determine if a previous change to the same record has occurred. If there is a record in the o_line.tmp file, the o_line_tmp$ template is loaded with the record information, and the program branches to the load_changed_info label for updating the o_line_tmp$ record template.

If a record does not exist in the o_line.tmp file, the program switches on the value in the variable add_item_flag%.

When the add_item_flag% value is 0 (the order line information is not being added as new), the o_line_tmp$ template is loaded with information from the o_line file, and then loaded with the changed information.

When the add_item_flag% value is not 0 (new order line being added), the o_line_tmp$ string template is dimensioned based on the O_line_template$, loaded with the appropriate values, and then loaded with the changed information.

11210 READ RECORD(F_O_LINE_TMP%,KEY=O_LINE_KEY$,DOM=11230)O_LINE_TMP$

11220 GOTO LOAD_CHANGED_INFO

   

11230 SWITCH ABS(SGN(ADD_ITEM_FLAG%))

   

11240 CASE 0

11250 READ RECORD(F_O_LINE%,KEY=O_LINE_KEY$)O_LINE_TMP$

11260 BREAK

   

11270 CASE 1

11280 DIM O_LINE_TMP$:O_LINE_TEMPLATE$

11290 LET O_LINE_TMP.ORDER_NUM$=STR(NUM(GML_TPL.COL$[1]):"00000000")

11300 LET O_LINE_TMP.LINE_NUM$=STR(NUM(GML_TPL.COL$[2]):"00000000")

11310 LET O_LINE_TMP.QTY_SHIPPED=0

11320 LET O_LINE_TMP.DISC_PCT=0

11330 LET O_LINE_TMP.DISC_AMOUNT=0

11340 BREAK

11350 SWEND

   

11360 LOAD_CHANGED_INFO:

11370 LET O_LINE_TMP.ITEM_NUM$=STR(NUM(ITEM_ID$):"000000")

11380 LET O_LINE_TMP.QTY_ORDERED=NUM(GML_TPL.COL$[5])

11390 LET O_LINE_TMP.PRICE=ITEM.PRICE

11400 LET O_LINE_TMP.LINE_WEIGHT=LINE_WEIGHT

11410 LET CHANGE_FLAG%=CHANGE_FLAG%+1

   

The changed order line item information is then written to the O_line.tmp file as follows:

11420 WRITE RECORD(F_O_LINE_TMP%)O_LINE_TMP$

   

All changes to order line items are logged and stored in a mkeyed file named up_log.tmp. This file is used in subroutine gml_f to determine if the record information in the o_line.tmp file is to be substituted for the information residing in the o_line file.

The next segment of code manages the updating of the up_log.tmp file:

   

11430 REM +-------------------+

11440 REM ! UPDATE LOG FILE !

11450 REM +-------------------+

11460 SWITCH ABS(SGN(ADD_ITEM_FLAG%))

   

11470 CASE 0

11480 LET UP_LOG.ACTION$="C"

11490 WRITE

RECORD(F_UP_LOG%,KEY=KEYP(F_O_LINE_TMP%),DOM=11500)UP_LOG$; GOTO

11490: 11530

   

11500 READ RECORD(F_UP_LOG%,KEY=KEYP(F_O_LINE_TMP%))UP_LOG$

   

11510 IF UP_LOG.ACTION$="D" THEN LET UP_LOG.ACTION$="C"; WRITE

RECORD(F_UP_L

11510:OG%,KEY=KEYP(F_O_LINE_TMP%))UP_LOG$

11520 IF UP_LOG.ACTION$="A" THEN LET

T_COLOR$=GML.BLACK$,B_COLOR$=GML.GREEN$

11520:; BREAK

11530 LET T_COLOR$=GML.BLACK$,B_COLOR$=GML.CYAN$

   

11540 BREAK

   

When a new line item is added, the o_line file must also be updated, as in the following:

   

11550 REM +------------------------+

11560 REM ! UPDATE O_LINE FILE    !

11570 REM ! (ADDITIONS)          !

11580 REM +------------------------+

   

11590 CASE 1

11600 LET ADD_ITEM_FLAG%=0

11610 LET START_EDIT_FLAG%=1

11620 WRITE RECORD(F_O_LINE%)O_LINE_TMP$

11630 LET UP_LOG.ACTION$="A"

   

11640 WRITE RECORD(F_UP_LOG%,KEY=KEYP(F_O_LINE%))UP_LOG$

   

The remaining code segment performs various routine items, including the updating the grid with row colors indicating an added item.

   

11650 REM +-------------------------+

11660 REM ! UPDATE RELATED FILES, !

11670 REM ! CONTROLS STATUS, ETC   !

11680 REM +-------------------------+

11690 LET INC%=1; GOSUB ITEM_COUNT

11700 LET T_COLOR$=GML.BLACK$,B_COLOR$=GML.GREEN$

11710 PRINT

(SYSGUI)'CONTEXT'(1),'ENABLE'(0),'CONTEXT'(3),'ENABLE'(0),'CONTE

11710:XT'(0),'CONTEXT'(4),'ENABLE'(0),'CONTEXT'(0)

11720 SWEND

   

11730 LET NULL$=FNCOLORS$(T_COLOR$,B_COLOR$)

11740 CALL "GML::UPDATE"

11750 PRINT (SYSGUI)'ENABLE'(-1201,-1703)

11760 RETURN

   

p: Saving Changes:

In subroutine store_changes, changes to line items were stored In the o_line.tmp file. The save_changes routine makes the changes permanent by updating the o_line file based on the information contained in the up_log.tmp file and o_line.tmp file.

11770 REM +--------------------------+

11780 REM ! SAVE ALL CHANGES:       !

11790 REM ! UPDATE O_LINE FILE      !

11800 REM +--------------------------+

11810 SAVE_CHANGES:

11820 READ

RECORD(F_UP_LOG%,KEY=KEYF(F_UP_LOG%,END=11950),DIR=0)UP_LOG$

11830 READ RECORD(F_UP_LOG%,END=11950)UP_LOG$

   

11840 SWITCH ASC(UP_LOG.ACTION$)

   

11850 CASE ASC("A")

11860 CASE ASC("C")

11870 READ RECORD(F_O_LINE_TMP%,KEY=KEYP(F_UP_LOG%),END=11950)O_LINE$

11880 WRITE RECORD(F_O_LINE%)O_LINE$

11890 BREAK

   

11900 CASE ASC("D")

11910 REMOVE (F_O_LINE%,KEY=KEYP(F_UP_LOG%),ERR=11920); LET INC%=-1;

GOSUB I

11910:TEM_COUNT

11920 BREAK

11930 SWEND

11940 GOTO 11830

11950 RETURN

   

q: Temp Files Init:

The file_temp_init subroutine is used to clear all changed information that has been stored in files o_line.tmp and up_log.tmp. This subroutine is executed after subroutine save_changes has completed, or after information that changes should not be saved. Additional logic also resets the change_flag% variable, and disables certain menu items.

 

   

12190 REM +-------------------------+

12200 REM ! INITIALIZE TEMP FILES !

12210 REM +-------------------------+

12220 FILE_TMP_INIT:

   

12230 CLOSE (F_O_LINE_TMP%)

12240 INITFILE PATH$+"O_LINE.TMP"

12250 OPEN (F_O_LINE_TMP%)PATH$+"O_LINE.TMP"

   

12260 CLOSE (F_UP_LOG%)

12270 INITFILE PATH$+"UP_LOG.TMP"

12280 OPEN (F_UP_LOG%)PATH$+"UP_LOG.TMP"

   

12290 PRINT (SYSGUI)'DISABLE'(-1201,-1703)

12300 LET CHANGE_FLAG%=0

   

12310 RETURN

r: Direction Flag:

A new variable, SCROLL_DIR, has been added to the Template GML_RCD$. This variable specifies the direction of the pointer - either forward or backward. If the user scrolls down the grid, the variable returns the number of records that the file pointer is moving forward up to the amount of visible rows. If the number of rows exceeds the number of visible rows, then the variable returns the number of visible rows. The same logic is used for backward direction.