× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.