I can't explain why but this is normal behavior as far as I can remember.
As I recall w$key (and maybe the entire INFDS) is only "updated" during a
read. Writes put the original value back into w$key (and maybe the entire
INFDS).
I typically have F3 exit the program (no matter what screen the user is on)
and F12 go back a screen. I create an indicator variable named EndOfTime
and my DOW looks at it. When they hit F12, I leave the loop. When they hit
F3, I turn on EndOfTime and leave the loop. I never rely on the variables
in the INFDS after a write, open, or close is executed. I've been doing it
this way for 20 years so the exact reasons have been purged from my brain.
Not sure if that helps.
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Brad Stone
Sent: Tuesday, March 7, 2023 10:18 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
<rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Function Key on Subfile Program
It's been years since I've written a subfile program, but I have a question.
The program has a subfile (SFL01, CTL01, OVR01) as well as another screen
(SCR01).
The F3 key is defined on the subfile as well as the screen.
SCR01 is displayed when they take an option on a subfile record. The screen
is displayed and if they hit F3 we come back to the loop displaying the
subfile. F5 (refresh) is forced into the function key so the subfile is
refresh, but for some reason when we are initializing the subfile (writing
the CTL01 record) it's getting set back to F3, so then it exits the program
all together.
FGGFAS1D CF E WORKSTN
F SFILE(SFL01:RRN)
F INFDS(WDSUBF)
D WDSUBF DS
D W$KEY 369 369
D SFLPG# 378 379B 0
So, the W$KEY is what we check to see what function key they pressed. It's
x'40' on startup.
They go into the SCR01 and press F3 and it's x'33'. The value x'35' (F5) is
being forced into it so the subfile is refreshed... but during this code,
it's set back to x'33'.
C eval RRN = 0
C MOVEA '0010' *IN(31)
C WRITE CTL01
C MOVEA '0100' *IN(31)
The WRITE operation is where it gets set back. And of course that causes it
to exit out all together (which we don't want to happen).
I don't recall this happening before.. then again, it's been years since
I've done a subfile. :)
Bradley V. Stone
www.bvstools.com
Native IBM i e-Mail solutions for Microsoft Office 365, Gmail, or any Cloud
Provider!
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.