"Yes, but..."
In the DSPF DDS, try this:
A N16 SFLFOLD(CF01)
A 16 SFLDROP(CF01)
A SFLMODE(&SFL1MODE)
A SFLCSRRRN(&CRRN)
A RTNCSRLOC(*WINDOW &CROW &CCOL)
A RTNCSRLOC(*RECNAME &CREC &CFLD)
The SFLFOLD and SFLDROP lines are the ones to look at -- the others are useful for positioning your subfile and returning/setting the cursor in the subfile.
Note: I'm using the F1 key as the fold/drop key, and controlling the keywords with F16. I'm using F1 because it is NOT a standard or often-used function key in my shop.
Now in the RPG/ILE source, I set the mode to truncated in *INZSR:
C Eval *In16 = *On ¦ Start in
C Eval Sfl1Mode = *On ¦ truncated mode
In the mainline, when testing for the function key the user returns, I use a CASE block:
C Fkey CasEq fnExit EndScreenLoop Exit
C Fkey CasEq fnRefresh RefreshScreen Reload F5
C Fkey CasEq fnClear RefreshScreen Reload CLEAR
C Fkey CasEq fnPrevious EndScreenLoop Previous
C Fkey CasEq fnHelp ShowHelp Show help text
===> C Fkey CasEq fnFold FoldDrop Fold/Drop s'file
C Fkey CasEq fnPrint PrintScreen Show help text
C Sfl1SelDta CasNe Sfl1SelDtaCpy LoadScreen Reload screen
C Cas CheckScreen Check screen
C EndCs
The important line here is marked -- the function key fnFold is NOT CF01, but CF17, which is shown on the screen as the Fold/Drop function key.
(NOTE: I do not match the *INnn indicators with the CF/CAnn keys, I use the AID byte -- so don't think that CF17 = *IN17)
Click here to view the subroutine.
An easy switch, here. The user presses F17 to switch between truncated and folded, under program control. You can detect the subfile RRN under the cursor in this routine, and set CRRN so that on redisplay that record will be on the screen with the cursor still on it.
Now here is the BUT...
You can't get around the CF01 key. That's the key I specified for SFLDROP/SFLFOLD in the DDS. If the user presses F1, the screen will behave 'normally' and control will NOT return to your program.
This was first published in September 2004