0010 *
0020 * Program : TEXTCON2 (formerly
TESTCON2)
0030 *
System : TEST
0040 *
Title : Browse Select
...
0050 * Function : This program is used to browse the EMPLOYEES file
by a
0060 * selected descriptor (DEPT in this
example) and provide
0070 * additional functions apart from the
general Construct
0080
* features which have been
left in place.
0090 *
0100 * A "Page x of x pages"
appears at the upper right hand side
0110 * of the screen and increments/decrements
as the user scrolls
0120
* through the data.
0130 *
0140 * A restart is still available from
the Construct version,
0150 * the pagination is refreshed for a
restart. Additionally,
0160 * a kind of wildcard function has
been added such that a
0170 * value typed in the restart field
followed by an asterisk
0180 * returns only the records for that
specific department;
0190 * the pagination refreshes for this
function as well.
0200 *
*
Browse EMPLOYEES by Department * Page 1
of 70 pages
______ <<==
Restart value: use xxxx* to select specific group
Dept Sec
Position
_ ADMA . 01 . RECEPTIONIST 454
_ ADMA . 01 . ADMINISTRATIONSCHEF 458
_ ADMA . 01 . DIREKT@R 1006
_ ADMA . 01 . EFG-ELEV 1017
_ ADMA . 01 . SEKRET#R 1028
_ ADMA . 02 . KONTORASSISTENT 451
_ ADMA . 02 . @KONOMICHEF 483
_ ADMA . 02 . REVISOR 1002
_ COMP . 01 . SECRETAIRE COMPTABLE 26
_ COMP . 01 . AGENT DE MAITRISE 74
_ COMP . 01 . CHEF DE SERVICE 115
_ COMP . 01 . COMPTABLE 124
_ COMP . 01 . CHEF COMPTABLE 192
_ COMP . 01 . CONTROLEUR DE GESTION 220
_ COMP . 01 . SECRETARIA 388
_ COMP . 01 . AGENT DE MAITRISE 772
Mark 'X' to Select, E=Exit, PF7=Back, PF8=Frwd
Figure 1.1 – Default
data, ALL DEPTs in sequence by DEPT and SECTION
Type TECH in the restart field and press ENTER:
*
Browse EMPLOYEES by Department * Page 1
of 18 pages
tech__ <<==
Restart value: use xxxx* to select specific group
*
Browse EMPLOYEES by Department * Page 1
of 18 pages
______ <<==
Restart value: use xxxx* to select specific group
Dept Sec
Position
_ TECH . 01 . CONSULTANT 109
_ TECH . 01 . SECRETAIRE DE DIRECTION 110
_ TECH . 01 . DIRECTEUR INFORMATIQUE 111
_ TECH . 01 . SECRETARIA 320
_ TECH . 01 . ASISTENTE TECNICO 401
_ TECH . 01 . SECRETARY 767
_ TECH . 01 . INGENIEUR TECHNICO. COMM. 776
_ TECH . 01 . INGENIEUR TECHNICO. COMM. 782
_ TECH . 01 . TECHNICAL ASSISTANT 862
_ TECH . 01 . TECHNICIAN 913
_ TECH . 01 . TECHNICIAN 963
_ TECH . 01 . TECHNICAL MANAGER 973
_ TECH . 01 . TECHNICIAN 1110
_ TECH . 02 . DIRECTEUR FINANCIER 97
_ TECH . 02 . CONSULTANT 108
_ TECH . 02 . INGENIEUR TECHNICO. COMM. 200
Mark 'X' to Select, E=Exit, PF7=Back, PF8=Frwd
Figure 1.2 – Default
data, ALL DEPTs from TECH to the end; notice the
pages value.
Type TECH* in the restart field and press ENTER:
*
Browse EMPLOYEES by Department * Page 1
of 18 pages
tech*_
<<== Restart value: use xxxx* to select
specific group
* Browse
EMPLOYEES by Department * Page 1 of 12
pages
______ <<==
Restart value: use xxxx* to select specific group
Dept Sec
Position
_ TECH . 01 . CONSULTANT 109
_ TECH . 01 . SECRETAIRE DE DIRECTION 110
_ TECH . 01 . DIRECTEUR INFORMATIQUE 111
_ TECH . 01 . SECRETARIA 320
_ TECH . 01 . ASISTENTE TECNICO 401
_ TECH . 01 . SECRETARY 767
_ TECH . 01 . INGENIEUR TECHNICO. COMM. 776
_ TECH . 01 . INGENIEUR TECHNICO. COMM. 782
_ TECH . 01 . TECHNICAL ASSISTANT 862
_ TECH . 01 . TECHNICIAN 913
_ TECH . 01 . TECHNICIAN 963
_ TECH . 01 . TECHNICAL MANAGER 973
_ TECH . 01 . TECHNICIAN 1110
_ TECH . 02 . DIRECTEUR FINANCIER 97
_ TECH . 02 . CONSULTANT 108
_ TECH . 02 . INGENIEUR TECHNICO. COMM. 200
Mark 'X' to Select, E=Exit, PF7=Back, PF8=Frwd
Figure 1.3 – Default
data, ALL TECHs only; there are 12 pages of employees
in
the
TECH department.
0210 DEFINE DATA
/* Global Data Area
0220 LOCAL
0230 *
0240
* Constants.
Modify #MAX-PAGES to identify how much scrolling
you want the program to support.
Currently the user can scroll all the way to the
end of the data but can only buck up 80 screens (or pages) of data with the PF7
key.
0250 01 #MAX-PAGES(P3) CONST<80> /* Maximum scroll pages.
0260 01 #MAX-PANELS(P3) CONST<1> /* Max left/right panel.
This version of the program provides 16 lines of
selection. Changing these value is permitted but
you’ll have to do a little work with the INPUT NO ERASE used to prompt for
actions.
0270 01 #SEL-TBL-SIZE(P3) CONST<16>
0280 01
#TOTAL-ACTION-LINES(P3)CONST<16>/* Max sel lines
0290 01 #UNCONDITIONALLY(L) CONST<TRUE> /* Used to REJECT
always.
0300 *
0310
* Miscellaneous local variables.
0320 01 #ACTION(A1)
0330 01
#BKWRD-TABLE-DECREMENT(P1) /* Bkwrd scroll
table decrement.
0340 01 #END-OF-DATA(L)
/* End of logical read.
0350 01
#END-OF-PAGE-LINE(P5) /* Line number where EOP starts.
Change these format and length setting to match your primary key.
In this example, the descriptor DEPT is the primary key and it is an A6 field.
0360 * Save
first key and ISN found in case scroll back record was deleted.
0370 01 #FIRST
0380 02 #KY(A06) /* 1st KEY when looking
for match.
0390 02 #ISN(P10) /* 1st ISN when looking for
match.
0400 01 #FIRST-ACTION-LINE(P3)
INIT<6>
0410 /* Line where action column starts
0420 01 #FIRST-INPUT(L) INIT<TRUE> /* Trigger End of Page.
0430 01
#FIRST-ISN-FOUND(L) /* Found the first ISN
0440 01 #FORWARD(L) INIT<TRUE> /* Not backwards left or right.
0450 01 #IN-BATCH(L)
/* Batch mode.
Change this setting to the size of your primary
key. The redefines may be used to work with specific elements of the elementary
field.
0460 * Define
input fields.
0470 01 #INPUT
0480 02 DEPT(A06) /* Input key value.
0490 02 REDEFINE DEPT
0500 03
DEPARTMENT-ABBR(A04)
0510 03 SECTION-CODE(A02)
0520 01 REDEFINE
#INPUT
0530 02 #FIRST-CHAR-ON-SCREEN(A1) /* Allow '.' to terminate.
0540 01
#INSIDE-READ-LOOP(L) /* Executing statement inside read.
Change these format and length settings to match
your primary key.
0550 * Value of
the scroll key on current record
0560 01 #KEY(A06) /* Key of record.
0570 01
#KEY-CV(C) INIT<(AD=I)> /* Determine if key was modified.
0580 01 #NEXT-LINE(P3)
/* Next screen line to be written.
0590 01 #NULL-KEY(A06)
/* Null key of record.
0600 01 #NULL-ISN(P10) /* Null ISN of record.
0610 01 #NULL-ACTION(A1)
0620 01 #MATCH-FOUND(L)
/* Matched Unique Id from table.
0630 01
#REDISPLAY-SCREEN(L) /* If true, don't scroll forward.
0640 01
#SCR-CV(C) INIT<(AD=I)> /* Determine if any field modified.
0650 01 #SEL-INDX(P5)
/* Select table index.
Change these format and length settings to match
your primary key.
0660 01 #SEL-TBL(1:#TOTAL-ACTION-LINES) /* Selection table.
0670 02 #KY(A06)
0680 02 #ISN(P10)
0690 02 #ACTIONS(A1) /* Function code column.
0700 02 #ACTION-CV(C) INIT<(AD=NP)> /* Control var. for func.
code col
Change #SELECTS to identify the number and value
of each valid action.
This code will go in the PROCESS-SELECTED-RECORD
paragraph.
0710 01 #SELECTS(A1/4)
0720 INIT (V) <'X','S','I','C'>
Change these format and length settings to match
your primary key.
0730 01 #SELECTED-KEY(A06)
/* Key of selected record.
0740 01
#SELECTED-ISN(P10) /* ISN of selected record.
0750 *
Change these format and length settings to match
your primary key.
Two “keys” have been established to provide for a range retrieval.
0760
* Key value for starting position of read.
0770 01 #START
0780 02 #KY(A06)
0790 02 REDEFINE #KY
0800 03 FILLER 4X
0810 03 #LOVAL(A2)
0820 02 #ISN(P10)
0830 01 #END
0840 02 #KY(A06)
0850 02 REDEFINE #KY
0860 03 FILLER 4X
0870 03 #HIVAL(A2)
0880 02 #ISN(P10)
0890 *
0900 * Tables
for backward/sideways scrolling feature
0910 01 #SCROLL-INDX(P3)
/* Index of Scroll Table.
Change these format and length settings to match
your primary key.
0920 01 #SCROLL-TBL(1:#MAX-PAGES)
0930 02 #KY(A06) /* Store top key/page.
0940 02 #ISN(P10) /* Store top ISN on each
page.
0950 01
#STD-KEY-PRESSED(L) /* Return, Quit, Flip,
0960 01 #TOP-LINE(P3)
0970 01 #TOP-OF-PAGE(L)
/* Top of Page was triggered.
0980 01 #TOTAL-PAGES(P3)
0990 01 #LAST-PAGE(P3)
1000 01 #FIND-NUMBER(I2)
Views and user-defined variables
specific to this application.
1010 *
1020
* Views.
1030 *
1040
* Primary view being scrolled.
1050 01
TEST-RECORD VIEW OF EMPLOYEES
1060 02 DEPT
1070 02 REDEFINE DEPT
1080 03 DEPART (A04) /* Client substitute
1090 03 SECTION (N02) /* Server substitute
1100 02 JOB-TITLE /* Service substitute
1110 01 #USERID(A8)
1120 END-DEFINE
For testing, when an action is selected a pop-up
window will appear verifying the action requested and the values from the
current record that can be used in processing the record. This si also found in the PROCESS-SELECTED-RECORD paragraph.
1130 DEFINE WINDOW
PICACT
1140 CONTROL SCREEN
1150 FRAMED OFF
1160 FORMAT KD=OFF
LS=132 PS=21 SG=OFF ES=OFF ZP=OFF IP=OFF
1170 SET KEY ALL
1180 SET KEY
PF3='%%'
1190 *
1200 * The following code is where the
passed values for starting the
1210 * read are
stored
1220 *
1230 MOVE 'AAAA'
TO #INPUT.DEPARTMENT-ABBR
1240 MOVE 00 TO
#INPUT.SECTION-CODE
1250 ASSIGN #END.#KY = 'ZZZZ99'
You’ll need to make the appropriate adjustments to
the lines above. If the primary key value is being passed from an external
source, you’ll need to identify that variable here and use it throughout the
program. If it comes from the application GDA you’ll follow the same procedure
to install the variable throughout the program.
This program is “range” driven hence the #START
and #END variables. These settings are for the default “FULL” range of records.
1260 SET CONTROL
'Q'
1270
PROG. REPEAT
1280 RESET #FIRST-ISN-FOUND #REDISPLAY-SCREEN
#MATCH-FOUND
1290 IF #SCROLL-INDX LT 1 THEN
1300 ASSIGN #FORWARD = TRUE
1310 END-IF
1320 IF #FORWARD THEN
1330 ASSIGN #START.#KY
= #INPUT.DEPT
Set to the name of your primary key. The
PAGINATION-SETUP uses the starting and ending keys to generate the page counts
in the headings.
1340 PERFORM PAGINATION-SETUP
1350 ASSIGN #MATCH-FOUND = TRUE
1360 ELSE
1370 ASSIGN #START.#KY
= #SCROLL-TBL.#KY(#SCROLL-INDX)
1380 ASSIGN #START.#ISN
= #SCROLL-TBL.#ISN(#SCROLL-INDX)
1390 END-IF
1400 *
1410 NEW-READ. REPEAT
1420 IF #FIRST-INPUT THEN
1430 RESET #FIRST-INPUT
1440 WRITE ' '
1450 NEWPAGE
1460 END-IF
1470 *
1480 RESET #END-OF-DATA
1490 *
Turn this READ into your view and primary key.
1500 READ-FILE. READ TEST-RECORD BY DEPT
1510 STARTING FROM #START.#KY THRU #END.#KY
1520 ASSIGN #INSIDE-READ-LOOP = TRUE
Change this entry to your primary key.
1530 ASSIGN #KEY = TEST-RECORD.DEPT
1540 DECIDE FOR FIRST CONDITION
1550 WHEN #FORWARD IGNORE
1560 WHEN #MATCH-FOUND IGNORE
1570 WHEN *ISN(READ-FILE.)
= #START.#ISN
1580 ASSIGN #MATCH-FOUND = TRUE
1590 WHEN NONE
1600 IF NOT
#FIRST-ISN-FOUND THEN
1610 ASSIGN #FIRST.#ISN
= *ISN(READ-FILE.)
1620 ASSIGN #FIRST.#KY
= #KEY
1630 ASSIGN #FIRST-ISN-FOUND = TRUE
1640 END-IF
1650 IF #KEY > #START.#KY
THEN
1660 ASSIGN #SCROLL-TBL.#KY(#SCROLL-INDX) = #FIRST.#KY
1670 ASSIGN #SCROLL-TBL.#ISN(#SCROLL-INDX) = #FIRST.#ISN
1680 PERFORM EXIT-READ-LOOP
1690 ELSE
1700 REJECT #UNCONDITIONALLY
1710 END-IF
1720 END-DECIDE
This is your detail output line. You may only
start in the 6th print position which means you only have 73
positions on the line to work with. Good luck. This is because Construct has set
up its Action column along the left hand margin of the map; you can adjust if
you need more room but you may have to make additional adjustments for the
INPUT statement later in the program as it “overlays” the detail display.
1730 WRITE NOTITLE NOHDR
1740 6T DEPART '.' SECTION (AD=Z)'.'
JOB-TITLE *ISN
1750 PERFORM UPDATE-SELECTION-TABLE
1760 END-READ
1770 *
1780 AT TOP OF PAGE
1790 ASSIGN #TOP-OF-PAGE = TRUE
1800 ASSIGN
#BKWRD-TABLE-DECREMENT = 1
1810 RESET INITIAL #SEL-TBL(*) /* Clear select table.
1820 IF #FORWARD AND #INSIDE-READ-LOOP THEN
1830 ADD 1 TO #SCROLL-INDX
1840 IF #SCROLL-INDX GT #MAX-PAGES THEN
1850 ASSIGN #SCROLL-INDX = #MAX-PAGES
1860 MOVE BY NAME #SCROLL-TBL(2:#MAX-PAGES)
1870 TO #SCROLL-TBL(1:#MAX-PAGES
- 1)
1880 END-IF
1890 ASSIGN #SCROLL-TBL.#KY(#SCROLL-INDX)
= #KEY
1900 ASSIGN #SCROLL-TBL.#ISN(#SCROLL-INDX)
= *ISN(READ-FILE.)
1910 END-IF
1920 ASSIGN #TOP-LINE = #FIRST-ACTION-LINE
This statement comprises the screen headers and
sub-headers and just about anything you want to appear at the top of your
screen. We’ve tried to follow a bit of a convention here but you can make
adjustment as you see fit. We used a PRINT statement to aid in making the
display of “Page n of n pages” easier to work with. There are seven lines at
the top you can work with.
1930 PRINT *DATX *TIMX(EM=ZH:IIAP)
1940 30T '* * BROWSE-SELECT * *'
1950 / #USERID 26T '* Browse EMPLOYEES by
Department *'
1960 60T 'Page' #SCROLL-INDX (AD=L) 'of'
#TOTAL-PAGES (AD=L)'pages'
1970 /// 6T 'Dept Sec
Position'
1980 END-TOPPAGE
1990 AT END OF PAGE
2000 PERFORM
UPDATE-SELECTION-TABLE
2010 PROTECT.
2020 FOR #SEL-INDX = 1 TO
#TOTAL-ACTION-LINES
2030 IF #SEL-TBL.#ISN(#SEL-INDX)
= #NULL-ISN THEN
2040 MOVE (AD=NP) TO #SEL-TBL.#ACTION-CV(#SEL-INDX)
2050 ELSE
2060 MOVE (AD=I) TO #SEL-TBL.#ACTION-CV(#SEL-INDX)
2070 END-IF
2080 END-FOR /* PROTECT.
2090 ASSIGN #NEXT-LINE = 1
2100 IF #END-OF-DATA OR NOT #IN-BATCH THEN
You can make some small changes to the INPUT
statement but only a few. Here we changed the prompt for the primary key that
can be used to retrieve a new group of data or restart the general display of
records for scrolling. You’ll want to alter the last line to reflect your
user’s selectable actions.
2110 INPUT NO ERASE (AD=TIML'_'
CV=#SCR-CV PS=24)
2120 3/6 #INPUT.DEPT (AD=AITL CV=#KEY-CV)
2130 '<<== Restart value: use xxxx* to select specific group'
2140 6/2 #SEL-TBL.#ACTIONS(01) (CV=#ACTION-CV(01))
2150 7/2 #SEL-TBL.#ACTIONS(02)
(CV=#ACTION-CV(02))
2160 8/2 #SEL-TBL.#ACTIONS(03)
(CV=#ACTION-CV(03))
2170 9/2 #SEL-TBL.#ACTIONS(04)
(CV=#ACTION-CV(04))
2180 10/2 #SEL-TBL.#ACTIONS(05) (CV=#ACTION-CV(05))
2190 11/2 #SEL-TBL.#ACTIONS(06)
(CV=#ACTION-CV(06))
2200 12/2 #SEL-TBL.#ACTIONS(07)
(CV=#ACTION-CV(07))
2210 13/2 #SEL-TBL.#ACTIONS(08)
(CV=#ACTION-CV(08))
2220 14/2 #SEL-TBL.#ACTIONS(09) (CV=#ACTION-CV(09))
2230 15/2 #SEL-TBL.#ACTIONS(10)
(CV=#ACTION-CV(10))
2240 16/2 #SEL-TBL.#ACTIONS(11)
(CV=#ACTION-CV(11))
2250 17/2 #SEL-TBL.#ACTIONS(12)
(CV=#ACTION-CV(12))
2260 18/2 #SEL-TBL.#ACTIONS(13) (CV=#ACTION-CV(13))
2270 19/2 #SEL-TBL.#ACTIONS(14)
(CV=#ACTION-CV(14))
2280 20/2 #SEL-TBL.#ACTIONS(15)
(CV=#ACTION-CV(15))
2290 21/2 #SEL-TBL.#ACTIONS(16)
(CV=#ACTION-CV(16))
2300 23/2 'Mark "X" to Select,
E=Exit, PF7=Back, PF8=Frwd'
2310 PERFORM VALIDATE-ACTION-CODES
2320 *
2330 IF #STD-KEY-PRESSED THEN
2340 ASSIGN #FORWARD = FALSE
2350 PERFORM EXIT-READ-LOOP
2360 END-IF
2370 /* Batch handling
2380 IF *DEVICE = 'BATCH' THEN
2390 ASSIGN #IN-BATCH = TRUE
2400 SET CONTROL
'H'
2410 ASSIGN #FORWARD = TRUE
2420 PERFORM EXIT-READ-LOOP
2430 END-IF
2440 DECIDE ON FIRST *PF-KEY
2450 VALUE 'PF7'
2460 IF #SCROLL-INDX LE
#BKWRD-TABLE-DECREMENT THEN
2470 REINPUT 'Top of scroll session
' ALARM
2480 END-IF
2490 SUBTRACT #BKWRD-TABLE-DECREMENT
FROM #SCROLL-INDX
2500 ANY
2510 ASSIGN #FORWARD = FALSE
2520 PERFORM EXIT-READ-LOOP
2530 NONE
2540 IF NOT(*PF-KEY
= 'ENTR' OR = 'PF8') THEN
2550 REINPUT 'Invalid program
function key ' ALARM
2560 END-IF
2570 ASSIGN #FORWARD = TRUE
2580 END-DECIDE
2590 DECIDE FOR FIRST CONDITION
2600 WHEN
#KEY-CV MODIFIED /* new start value or specific group
2610 RESET #SCROLL-INDX