If some of your workstations support pointer devices (i.e., a mouse), you may want to consider adding scroll bars to your subfile programs. This nifty new feature can give some of your tired, old subfile programs a new look, and it can add a little glitz and glamour to your software programs.
The scroll bar has been a mainstay of graphical operating environments such as OS/2 and Windows for a long time. If you have ever run an application under any of these operating systems, you already know what the scroll bar is all about.
The AS/400 scroll bar works much as it would with the other graphical interfaces, in that it has a scroll box to indicate how big the subfile is and where you are within it. The mouse pointer can be positioned on the scroll bar's up or down arrows, and the subfile will move forward and back one record at a time when the mouse button is pressed. (Shifting the subfile one record at a time wasn't something you could do very easily until now.) The mouse can also be used to drag the scroll box to the desired position within the subfile.
The new scroll bar feature was made available as part of V3R1. You will get three different results depending on the type of workstation you use.
1. The best results are with intelligent workstations using certain emulation software such as RUMBA/400 and PC400 or InfoWindow II terminal displays (3486, 3487, or 3488) attached to an enhanced interface controller. With these types of workstations, the scroll bar will be displayed graphically and the mouse can be used to position the scroll bar.
2. Some terminals attached to the enhanced interface controller or intelligent workstations using certain emulation software (e.g., PC Support WSF) will display the scroll bar in character mode. In this environment, mouse support is unavailable; paging is accomplished through use of the roll keys or page keys.
3. Some terminals attached to the enhanced controller, all terminals attached to the non-enhanced controller, and intelligent terminals attached through certain emulation software (e.g., OS/2 Communication Manager) won't display the scroll bar. The display file acts as if the scroll bar function wasn't specified.
In this article, we'll show you how to implement scroll bars into your subfile programs. We're going to be discussing some specific subfile techniques, so we'll assume that you have at least a basic understanding of subfile concepts. The techniques we'll be showing you will enable you to enhance both the appearance and the functionality of your subfile programs.
What Has to Be Done to Start?
To activate the graphical scroll bar, simply specify the new *SCRBAR output option parameter for the DDS Subfile End (SFLEND) keyword. Before you change all of your subfiles, there are a few things you should consider.
If you use the *SCRBAR parameter in the SFLEND keyword, the three rightmost characters of your subfile record must not be used to leave room for the scroll bar to appear on the screen. This restriction is similar to the extra blank line that must be left below your subfile when using the *MORE parameter of the SFLEND keyword.
By the very nature of the page-at-a-time and load-all styles of subfiles, the scroll bar option is a lot more functional with the latter than it is with the former. If you use a page-at-a-time subfile, the scroll box within the scroll bar could be somewhat misleading because it represents the number of records that are currently in the subfile and not those that could ultimately end up there. When utilized in a load-all subfile, the scroll box is a much fairer representation of the relative position your display is at within the file. The reason for this is because all of the records are written to the subfile before it is ever displayed.
1 shows what the subfile scroll bar looks like for a sample subfile program that displays a list of state codes. The display file (SCR002DF) can be found in 2, and the RPG program (SCR002RG) can be found in 3. This example was run on a PC using IBM's PC400 emulation connectivity product. It would also work on a PC using RUMBA/400 or Client Access PC5250 emulation.
Figure 1 shows what the subfile scroll bar looks like for a sample subfile program that displays a list of state codes. The display file (SCR002DF) can be found in Figure 2, and the RPG program (SCR002RG) can be found in Figure 3. This example was run on a PC using IBM's PC400 emulation connectivity product. It would also work on a PC using RUMBA/400 or Client Access PC5250 emulation.
The look and feel of the scroll bar you see may vary depending upon the user interface and workstation controller you employ. The AS/400 Application Display Programming manual has a section on hardware configuration which lays out all of the possible workstation and controller combinations and how scroll bars will work with each.
A Few Words About the Code
While there is nothing remarkable about any of the code in this article, a few of the new DDS keywords should be explained.
When using the *SCRBAR parameter of the SFLEND keyword, you can also specify the *MORE or *PLUS parameter. The additional parameter is available so the system will know which option to exercise when the application is run from a non-graphical workstation. We used the *MORE parameter in this example.
The SFLSCROLL keyword used is unique to subfiles that have the scroll bar. When employed, it will return the value of the relative record number of the subfile record that happens to be at the top of the screen when control is returned to the RPG program. Because the subfile paging is handled at the controller level and not within the RPG program, this keyword is valuable when you need to redisplay the subfile at the same page that was displayed before you displayed some other screen.
Take the record number returned from the SFLSCROLL keyword and load it into the hidden field associated with the SFLRCDNBR before you redisplay the subfile. We illustrate this technique in SCR002RG by redisplaying the subfile when the Enter key is pressed. Before we redisplay it, we load the value from the current position (CURPOS) field returned from the SFLSCROLL keyword to the set position (SETPOS) field. Since SETPOS is linked to the SFLRCDNBR keyword, the subfile is forced to display the same page. To see the technique in action, call SCR002RG, page forward at least one page, and press Enter. The same page will be redisplayed.
The RPG program has been coded as a load-all subfile, meaning that the entire subfile is loaded prior to presenting it to the screen. All paging activities will occur at the controller level, so there is no need to code the page or roll keywords into the subfile DDS.
There is one thing we feel we should warn you about. IBM is still working out bugs on V3R1 (as any of us who have it installed are keenly aware). We experienced several quirks in the operation of this program depending upon which PTF level we were at that day. The bugs we experienced seemed to be centered around trying to display the subfile within a DDS window. At one point, the system treated an input field on the first subfile record as a protected field (even though subsequent subfile records were fine). At another point, the subfile would paint the screen, but an I/O error would then occur. Removing the window always seemed to take care of the problems, though.
Hooray for Hollywood!
We are confident that IBM will get the glitches worked out. Bugs aside, the scroll bar is a significant addition to our beloved subfile. While the evolution to an AS/400 graphical user environment has at times seemed painstakingly slow, IBM is on the right track.
It is unrealistic to think that all AS/400 shops will be able to afford wonderful client/server tools such as VisualAge or Visual RPG. While the cost of the tools has dropped significantly, the overall cost of redevelopment has not. Personnel cost has and will continue to be the principal cost in redesigning our legacy systems.
Kudos to IBM for continuing to give us tools that allow us to produce better software. Powerful DDS functions such as windows, menu bars, and now scroll bars are very positive steps toward extending the life of AS/400 software (and tired old RPG programmers like us).
Doug Pence is the founder and Ron Hawkins is the research and development manager of Computer Processing Unlimited, Inc. in San Diego, California.
REFERENCE
AS/400 Application Display Programming (SC41-3715, CD-ROM QBKAUK00).
Subfile Scroll Bars
Figure 1: The Subfile Scroll Bar
Subfile Scroll Bars
Figure 2: SCR002DF Display File Utilizing the Subfile Scroll Bar
*=============================================================== * To compile: * * CRTDSPF FILE(XXX/SCR002DF) SRCFILE(XXX/QDDSSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A DSPSIZ(24 80 *DS3) A CA03(03) A R SFLRCD SFL A SFDESC 30A O 5 2 A SFLCOD 2A O 5 35 A R SFLCTL SFLCTL(SFLRCD) A OVERLAY A SFLDSP A SFLDSPCTL A N03 SFLEND(*SCRBAR *MORE) A SFLSIZ(0050) A SFLPAG(0017) A SETPOS 4S 0H SFLRCDNBR A CURPOS 5S 0H SFLSCROLL A 2 35'State Codes' A DSPATR(HI) A 4 2'Description' A DSPATR(HI) A 4 34'Code' A DSPATR(HI) A R FOOTER A 23 2'F3-Exit' A COLOR(BLU) *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
Subfile Scroll Bars
Figure 3: SCR002RG RPG Program Utilizing the Subfile Scroll Bar
*=============================================================== * To compile: * * CRTRPGPGM PGM(XXX/SCR002RG) SRCFILE(XXX/QRPGSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 FSCR002DFCF E WORKSTN F X KSFILE SFLRCD E ST 1 50 2 STD 30 * C Z-ADD1 SETPOS C DO 50 X 30 C MOVELST,X SFLCOD C MOVELSTD,X SFDESC C WRITESFLRCD C ENDDO * C WRITEFOOTER C EXFMTSFLCTL * * Redisplay subfile at current page * to demonstrate SFLSCROLL keyword C *IN03 IFEQ *OFF C Z-ADDCURPOS SETPOS C WRITEFOOTER C EXFMTSFLCTL C ENDIF * C MOVE *ON *INLR *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ** AKALASKA ALALABAMA ARARKANSAS AZARIZONA CACALIFORNIA COCOLORADO CTCONNECTICUT DEDELAWARE FLFLORIDA GAGEORGIA HIHAWAII IAIOWA IDIDAHO ILILLINOIS ININDIANA KSKANSAS KYKENTUCKY LALOUISIANA MAMASSACHUSETTS MDMARYLAND MEMAINE MIMICHIGAN MNMINNESOTA MOMISSOURI MSMISSISSIPPI MTMONTANA NCNORTH CAROLINA NDNORTH DAKOTA NENEBRASKA NHNEW HAMPSHIRE NJNEW JERSEY NMNEW MEXICO NVNEVADA NYNEW YORK OHOHIO OKOKLAHOMA OROREGON PAPENNSYLVANIA RIRHODE ISLAND SCSOUTH CAROLINA SDSOUTH DAKOTA TNTENNESSEE TXTEXAS UTUTAH VAVIRGINIA VTVERMONT WAWASHINGTON WIWISCONSON WVWEST VIRGINIA WYWYOMING
LATEST COMMENTS
MC Press Online