Hi Patrik,
Once you get the page built, regardless of how it is done what is your
goal ?
How many different colour requirements for each day and what do they mean.
What editing if any can the user do ?
Sometimes the end result can help guide you on the how.
Thanks
Don
From: "Patrik Schindler" <poc@xxxxxxxxxx>
To: "RPG programming on IBM i" <rpg400-l@xxxxxxxxxxxxxxxxxx>
Date: 22/02/2024 07:32 PM
Subject: [V4R5, positional] Array overlay to DSPF derived variables
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx>
Hello,
I'm contemplating about optimizing code for a calendar display showing a
whole year.
Each month is a row of a subfile, and one subfile line has fields named
DF_DAY01 to DF_DAY31, type char with two positions. This saves indicators
for various highlighting purposes (only 31 needed instead of 365).
At the moment, I'm using a "day" loop, counting from 1 to 31, CHAIN to the
according value in a PF and copy the result into the respective DSPF
fields, if there is a result at all.
C COMPKEY CHAIN BUCHUNGEN 73
B3 C *IN73 IFEQ *OFF
B4 C SELECT
C C_DAY WHENEQ '01'
C MOVE TYPKURZ DF_DAY01
C C_DAY WHENEQ '02'
C MOVE TYPKURZ DF_DAY02
C C_DAY WHENEQ '03'
C MOVE TYPKURZ DF_DAY03
…
This leads to an awful lot of conditionals and text. In C I would have
used what is called "variable variables", but as far as I've understood
this isn't a thing with (old) RPG.
Now I'm wondering if I could code an array with 31 elements of char with
two positions each. Instead of allocating storage, the elements should
eventually point to the memory locations of the respective display file
fields (DF_DAY01, etc).
I want to assign the addresses of the DSPF fields to the defined
individual array elements just once at program startup and later use array
modifications such as counter variables to significantly lessen the code
actually dealing with the DSPF fields (filling and clearing data within).
But… I still struggle to get the grip on pointers and base pointers in
RPG. Examples in the net are scarce for old positional code. I found an
example in positional code from Scott Klement (
https://www.scottklement.com/rpg/pointers.html) but I fail to map this to
my actual use case.
And I don't know if this could work with subfiles, where each line stores
distinct values and as such has distinct memory locations. Maybe this is
hidden from the programmer by lower layers?
I'd appreciate some comments or even example code.
Thank you!
:wq! PoC
As an Amazon Associate we earn from qualifying purchases.