0

How can i set color to specific records in a subfile on some condition execution? I have a display file where the SFL and CTL have been defined.Where can i refer the indicators in the DSP file or use them in the RPG to trigger appropriate conditioning.

For eg:

       Name      Age       Location
      Rosell     26        Amsterdam
      Smarkon    31        London
      Jack       40        Chicago
      Jim        22        Mauritius

I now want to display records in my subfile only of those whose age is greater than 30.(age>30) I want those records that have been retrieved in a different color.

techie
  • 467
  • 3
  • 8
  • 23

1 Answers1

5

Use numbered indicators in your display file to control the COLOR attributes like so:

.....AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+
                  S1AGE          3  0   5 12EDTCDE(Z)
    30                                  COLOR(BLU)

These number indicators in your display file records are passed back and forth to your RPG program in the display file's record formats. So, in your RPG, you set indicator 30 on or off depending on the value of the person's age. (Note: The following example is in free-form RPG.)

If S1AGE > 30;
  *IN30 = *On;
Else;
  *IN30 = *Off;
EndIf;

Or, if you like concise code in your RPG:

*IN30 = (S1Age > 30);
Tracy Probst
  • 1,839
  • 12
  • 13
  • Yes, although it's usually, good to overlay the display file (with `indds` and `infds`) to a DS type so that you can _name_ the variables. Nothing like working through a 6000 line program with only **numbers** to tell whether something is on/off... – Clockwork-Muse Jul 23 '12 at 16:10
  • @Tracy I tried using AGE IFGT 30 SETON 13 ENDIF in my RPG/400 Program,I have set 13 as indicator against the color.But it throws compile error of "Entries of factors 1 and 2 are not of same type"How else to implement in rpg 400. – techie Jul 23 '12 at 16:17
  • @X-Zero, that's a good point, but, I think, outside the scope of this answer. – Tracy Probst Jul 23 '12 at 19:07
  • @techie, check your AGE variable and make sure it's numeric and not alpha. If it's an alpha field, you should convert it to numeric, first. If you were using RPG IV (ILE), you could use the %INT function and wrap it all in a MONITOR block. – Tracy Probst Jul 23 '12 at 19:12