GML::UPDATE - Update Grid with Data from GML_TPL$ Template

Syntax

CALL "GML::UPDATE"

Description

This procedure updates grid data and attributes with the values contained in the GML_TPL$ template and then redraws the grid control. The GML_TPL$ template variable GML_TPL.ROW_N% is used to designate which row of data to update.

This procedure is normally used to update a single grid cell or cells in a row of the grid. When loading many cells, such as reading from a file, the LOAD procedure should be used.

Options

Setting GML_TPL.OPTION% to 1 prior to executing the UPDATE procedure will update grid data but not redraw the grid, nor will the currently selected cell be changed or deselected. A GML_TPL.OPTION% setting of 2 will cause the grid to be redrawn, but cell data and attributes will not be changed.

Setting variable GML_TPL.DEF_FLAG% to 4 will prevent the UPDATE procedure from executing the GML routine that administers the amount of visible rows that can be viewed beyond the last row of data that contains text

Example 1

Updating grid cell located in grid set 1, row 3, column 2 with text, and setting the grid cell text color to red.

2400 GML.SET%=1
2410 CALL "GML::TPL_PREP"
2420 GML_TPL.ROW_N%=3
2430 GML_TPL.COL$[2]="John Smith"
2440 GML_TPL.T_COLOR$[2]=GML.RED$
2450 CALL "GML::UPDATE"

 

Example 2

This example uses two procedures to exhibit when the UPDATE procedure is used with a GML_TPL.OPTION% set to a value of 2. Using the REFRESH procedure in place of the UPDATE procedure will also accomplish the same results.

2500 READ RECORD(4,END=2590)ITEM$
2510 ROW%=ROW%+1
2520 GML_TPL.COL$[1]=ITEM.NUM$
2530 GML_TPL.COL$[2]=ITEM.DESC$
2540 GML_TPL.COL$[3]=STR(ITEM.PRICE:"#,###,##0.00")
2550 GML_TPL.REL$[1]=KEYP(4)
2560 GML_TPL.ROW_N%=ROW%
2570 CALL "GML::LOAD"
2580 GOTO 2500
2590 CLOSE (4)
2600 CALL "GML::TPL_PREP"
2610 GML_TPL.OPTION%=2
2620 CALL "GML::UPDATE"

Example 3

Normally variable GML_TPL.ROW_N% contains a value between 1 to the maximum rows in the grid, and variable GML_TPL.COL_N% contains the value of 0. Setting GML_TPL.ROW_N% to –1 Is interpreted by program GML as an instruction to apply the update to all rows in the grid. In addition, setting GML_TPL.COL_N% to –1 instructs the GML to apply the changes contained in the template for column [1] to all columns in the grid. Therefore, setting GML_TPL.ROW_N% to –1 and GML_TPL.COL_N% to –1 will apply all changes in column [1] to the each cell in the entire grid. This feature is normally used to change grid attributes.

The following changes all cells in the main grid of grid set 1 to display the grid cell text with a background color of light gray and a text color of dark gray. In this example, variable GML_TPL.DEF_FLAG% is set to 2, which instructs program GML to update the main grid default background color to the background color in variable GML_TPL.B_COLOR$[1]. Using this feature improves the look of the grid as cells are being displayed. If, for instance, the cell background color was light gray and the default background color of the grid was white, the grid would appear to "flash" as the grid was being redrawn. Valid values for variable GML_TPL.DEF_FLAG% are:

0

no change

1

set default text color to value in GML_TPL.T_COLOR$[1]

2

set default background color to value in GML_TPL.B_COLOR$[1]

3

apply both value 1 and value 2 colors as grid default colors

2400 GML.SET%=1
2410 CALL "GML::TPL_PREP"
2420 GML_TPL.ROW_N%=-1
2430 GML_TPL.COL_N%=-1
2440 GML_TPL.B_COLOR$[1]=GML.LTGRAY$
2450 GML_TPL.T_COLOR$[1]=GML.DKGRAY$
2460 GML_TPL.DEF_FLAG%=2
2470 CALL "GML::UPDATE"

See Also

Visual PRO/5 Grid Management Library

Alphabetical Listing of GML Procedures