× 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.



Hi Pete,

In RPG III I would have written something like:

FIELD1    CHAIN   MYFILEFMT       97
*IN99     IFEQ      *ON
SETON 20 ENDIF
FIELD2    CHAIN  MYFILEFMT       97
*IN99     IFEQ      *ON
SETON 21 ENDIF

The problem with numeric indicators is that it's not possible to give them meaningful names. That makes your program difficult to read for the next guy. I think it's a really good idea to replace them with named indicators, even though it's a bit of a departure from RPG III, its a lot easier to read.

In RPG IV, you can specify the INDDS keyword on your F-spec. It tells the system that when reading the display file, you don't want to import the indicators into your prorgram. Instead, you want to map those indicators across a data structure.

To do that, you'll code something like this (to save e-mail space, I'll do only 5 fields):

     FSCREEN    CF   E             WORKSTN INDDS(ScreenInds)

     D ScreenInds      ds
     D   ExitKey                       N   overlay(ScreenInds:03)
     D   CancelKey                     N   overlay(ScreenInds:12)
     D   RIHI_Field                    N   overlay(ScreenInds:20)
     D                                     dim(5)

NOTE: You must have the INDARA keyword in your display file to use this.

If your display file has CF03(03) (or CA03(03)) so that indicator 03 is set on when F3 is pressed, the above example will call that idnicator "ExitKey" in your RPG program. It simply maps *IN03 of the display file to "ExitKey" in RPG -- just gives it a new name in the RPG. *IN03 in RPG will no longer reflect the exit key.

Likewise, you can do that with your reverse image/highlight fields. In the example above, I've used an array. Indicator 20 will map to RIHI_Field(1), Indicator 21 to RIHI_Field(2), etc. This is another beautiful thing about this data structure support...

You can map your FIELD1 FIELD2 FIELD3 to an array using a data structure as well:

     D ArrayFields     ds
     D   Field1
     D   Field2
     D   Field3
     D   Field4
     D   Field5
     D   Field                             like(Field1) Dim(5)

This defines an array named "Field" that has the same properties as Field1. Now you cna reference Field1 as FIELD(1), and Field2 as FIELD(2), etc.

This makes it easy to use a loop to verify the fields:

     D f               s             10I 0

     /free

          // set all RIHI indicators off.

          RIHI_Field(*) = *OFF;

          // set on the ones that aren't in MYFILEFMT:

          for f = 1 to 5;

             chain Field(f) MYFILEFMT;

             if not %found;
                RIHI_Field(f) = *ON;
             endif;

          endfor;

You can also blank out all of your selection fields by doing:

          FIELD(*) = ' ';

Much more elegant than RPG III, easier to read, easier to maintain the code because there's only one place where the CHAIN is done instead of many.

Just my opinion, of course.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.