|
|||||||
|
|
![]() |
|
|
|
|
||
|
Stay on the Same Subfile Page Hey, Ted: I'm sure this is a simple question, but maybe you'll answer it anyway. It would help me a lot. When the user presses Enter or a function key while a multi-page subfile is on the display, the first page of the subfile is redisplayed. How can I position the subfile to the page that was displayed when the Enter key or function key was pressed? --Jay It's a simple technique, Jay, but is one all green-screeners ought to know. Redisplaying the first page of a subfile is a major annoyance to users. You'll need to use two keywords in the subfile control format. The SFLCSRRRN keyword loads a five-digit hidden field with the relative record number of the subfile record upon which the cursor is located. If the cursor is not located on a subfile record, this field is zero. The other keyword is SFLRCDNBR, which causes the system to display the subfile page that contains a specified record. To put these keywords into action, you need to do two things in your program. First, set the field associated with the SFLCSRRRN keyword to zero before loading a subfile. Second, before displaying the subfile, set the field associated with the SFLRCDNBR to the value of the SFLCSRRRN field, unless that field is zero. In the case of a zero value, set the SFLRCDNBR field to 1. Here's an example display file that uses these keywords.
A DSPSIZ(24 80 *DS3)
A INDARA
A R S1SFL SFL
A 6 2'LOAD:'
A S1LOADNBR 3 0O +1EDTCDE(4)
A +1'REC:'
A S1RECNBR 3 0O +1EDTCDE(4)
A R S1CTL SFLCTL(S1SFL)
A SFLSIZ(11)
A SFLPAG(10)
A OVERLAY
A CA03(03 'EXIT')
A CF05(05 'REFRESH')
A CF10(10 'NEXT LOAD')
A SFLCSRRRN(&S1CSRRRN)
A 45 SFLDSP
A 44 SFLDSPCTL
A N44N45 SFLCLR
A 46 SFLEND(*MORE)
A S1CSRRRN 5S 0H
A S1RCDNBR 4S 0H SFLRCDNBR(CURSOR)
A S1SFLRRN 5S 0H
A R S1LEGEND
A 23 5'F3=Exit'
A +4'F5=Refresh'
A +4'F10=Next load'
Here's an RPG program to drive the display file.
Faa01d cf e workstn
F sfile(s1Sfl:s1SflRRN)
F indds(wsIndicators)
D true c const(*on)
D false c const(*off)
D wsIndicators ds 99
D s1ExitRequested...
D 3 3n
D s1RefreshRequested...
D 5 5n
D s1LoadRequested...
D 10 10n
D s1SflDspCtl 44 44n
D s1SflDsp 45 45n
D s1SflMore 46 46n
C eval s1LoadRequested = true
C eval s1SflMore = true
C
C dou s1ExitRequested
C if s1LoadRequested
C exsr s1Load
C elseif s1RefreshRequested
C exsr s1Refresh
C endif
C exsr s1Display
C enddo
C
C eval *inlr = *on
C* =================================================
C s1Display begsr
C
C eval s1SflDsp = true
C eval s1SflDspCtl = true
C
C if s1CsrRRN > *zero
C eval s1RcdNbr = s1CsrRRN
C else
C eval s1RcdNbr = 1
C endif
C
C write s1Legend
C exfmt s1Ctl
C
C endsr
C* ==============================================
C s1Load begsr
C
C eval s1LoadNbr += 1
C exsr s1Refresh
C
C endsr
C* ==============================================
C s1Refresh begsr
C
C exsr s1Clear
C for s1SflRRN = 1 to 50
C eval s1RecNbr = s1SflRRN
C write s1Sfl
C endfor
C eval s1CsrRRN = *zero
C
C endsr
C* ==============================================
C s1Clear begsr
C
C eval s1SflDsp = false
C eval s1SflDspCtl = false
C write s1Ctl
C
C endsr
When you run the program, you can press Enter or the F3, F5, or F10 keys. Pressing Enter redisplays the same page of the subfile. Pressing F5 rebuilds the subfile with the same data and positions to the first subfile page. Pressing F10 rebuilds the subfile with new data and positions to the first page. F3 ends the program. Notice that the s1CsrRRN field is set to zero when the subfile is cleared and reloaded. This forces a value of 1 into s1RcdNbr when the subfile is first displayed. As long as the user keeps the cursor on a subfile record, the system will redisplay the same page when the Enter key is pressed. --Ted
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |