* GridTest * * December 16, 1998 * * Enter revenue values into the grid at the appropriate months * for the appropriate authors. * * After the values are entered, click the Calculate! button * to calculate the totals. The values in the cells are * associated with currency values. * * This is a sample use of the grid control. * * Author. Brian Sullivan. * * Copyright 1997, 2000 LegacyJ Corporation, All rights reserved. * IDENTIFICATION DIVISION. PROGRAM-ID. GridTest. ENVIRONMENT DIVISION. CONFIGURATION SECTION. DATA DIVISION. WORKING-STORAGE SECTION. 01 MAIN-FRAME. 05 FRAME PIC X(28) VALUE "PERCobol(TM) Synkronix, Inc.". 10 EVENTWX. 10 BORDER-LAYOUT. 15 NORTH. 20 TEXTLABEL PIC X(19) VALUE "Synkronix Bookstore". 25 FONT PIC X(5) VALUE "Serif". 30 BOLD-FONT PIC X. 30 SIZE-FONT PIC 99 VALUE 24. 15 CENTER. 20 GRID. * The standard component properties such as background/foreground * color are available; note that they may not apply to all parts * as the grid is a comparatively complex component. For example, * the color applies only to the grid cells, not the headers. * These two are normally left at default, but can be changed * to not show the grid lines or to not allow cell editing, * updated on a build. * Optional properties. * 25 SHOWGRID PIC X VALUE "Y". * 25 CELLSELECTIONENABLED PIC X VALUE "Y". * These properties are read-only, updated on a build. * Optional properties. 25 GETEDITINGCOLUMN PIC 99. 25 GETEDITINGROW PIC 99. 25 ISEDITING PIC X. 25 ISOPAQUE PIC X. * Column headers; these must match the data provided later. 25 COLUMNS. 30 COL1 PIC X(7) VALUE "January". 30 COL2 PIC X(8) VALUE "February". 30 COL3 PIC X(5) VALUE "March". 30 COL4 PIC X(5) VALUE "April". 30 COL5 PIC X(3) VALUE "May". 30 COL6 PIC X(4) VALUE "June". 30 COLT PIC X(5) VALUE "Total". * Row headers; these are optional, but if present must match the data. 25 ROWS. 30 ROW1 PIC X(13) VALUE "King, Stephen". 30 ROW2 PIC X(14) VALUE "Jordan, Robert". 30 ROW3 PIC X(10) VALUE "Rice, Anne". 30 ROW4 PIC X(13) VALUE "Vinge, Vernor". 30 ROW5 PIC X(15) VALUE "Sullivan, Brian". 30 ROW6 PIC X(11) VALUE "Wolfe, Gene". 30 ROWT PIC X(5) VALUE "Total". * Data-item must be a two-dimensional table. The names within it are arbitrary. * The data items edited by the user are immediately available. * Data updated in this table must be updated by 'build' to be visible. 25 DATA-ITEMS. 30 COLUMNS OCCURS 7 TIMES. 35 ROWS OCCURS 7 TIMES. 40 ITEM PIC $$$$,$$$.$$. 15 SOUTH. 20 CALCULATE. 25 BUTTON PIC X(10) VALUE "Calculate!". * Temporary variables used in this sample. 01 TOTAL PIC 999999V99. 01 TEMP PIC 999999V99. 01 ROW USAGE INDEX. 01 COL USAGE INDEX. PROCEDURE DIVISION. MAIN-ENTRY. DISPLAY "Starting program " "(please wait for JFC initialization)..." UPON SYSOUT * Fill up the table with some initial values... move 11 to item (1 1) move 12 to item (1 2) move 13 to item (1 3) move 14 to item (1 4) move 15 to item (1 5) move 16 to item (1 6) move 17 to item (1 7) move 21 to item (2 1) move 22 to item (2 2) move 23 to item (2 3) move 24 to item (2 4) move 25 to item (2 5) move 26 to item (2 6) move 27 to item (2 7) move 31 to item (3 1) move 32 to item (3 2) move 33 to item (3 3) move 34 to item (3 4) move 35 to item (3 5) move 36 to item (3 6) move 37 to item (3 7) move 41 to item (4 1) move 42 to item (4 2) move 43 to item (4 3) move 44 to item (4 4) move 45 to item (4 5) move 46 to item (4 6) move 47 to item (4 7) move 51 to item (5 1) move 52 to item (5 2) move 53 to item (5 3) move 54 to item (5 4) move 55 to item (5 5) move 56 to item (5 6) move 57 to item (5 7) move 61 to item (6 1) move 62 to item (6 2) move 63 to item (6 3) move 64 to item (6 4) move 65 to item (6 5) move 66 to item (6 6) move 67 to item (6 7) move 71 to item (7 1) move 72 to item (7 2) move 73 to item (7 3) move 74 to item (7 4) move 75 to item (7 5) move 76 to item (7 6) move 77 to item (7 7) * Visibly show the frame and its contents. build frame of main-frame display "JFC initialized." upon sysout * Setup the event handlers. event frame of main-frame frame-handler event button of calculate calculator * End the initial thread, just wait for the user to intitiate an event. stop run. FRAME-HANDLER. HIDE FRAME OF MAIN-FRAME END-HIDE STOP ALL RUN. CALCULATOR. move 0 to total set row to 1 set col to 1 * display "Summing columns..." upon sysout perform test after varying row from 1 by 1 until row=7 move 0 to total perform test after varying col from 1 by 1 until col=7 move item (row col) to temp add temp to total end-perform move total to item (row 7) end-perform move 0 to total set row to 1 set col to 1 * display "Summing rows..." upon sysout perform test after varying col from 1 by 1 until col=7 move 0 to total perform test after varying row from 1 by 1 until row=7 move item (row col) to temp add temp to total end-perform move total to item (7 col) end-perform move 0 to total set row to 1 * display "Summing total..." upon sysout perform test after varying row from 1 by 1 until row=7 move item (row 7) to temp add temp to total end-perform move total to item (7 7) * Update data items in grid to new values in item table. build grid * display "Editing column " geteditingcolumn * " row " geteditingrow upon sysout * display "Is editing: " isediting upon sysout * display "Is opaque: " isopaque upon sysout * End the event stop run.