** This thread discusses the article: TechTip: Eliminate Indicators in Display Programs **
Eliminating Indicators in Display Programs is a good idea, but I also try to avoid them in the DDS whenever possible. That means instead of specifying indicators to set display attributes, I use a single character program field that is specified with the display attribute in DDS and fill this field in my RPG code with the appropriate hex values of the display attributes. A A1STS 1A P A R1STS R B 20 33REFFLD(STS LLREFDP) A TEXT('Status') A DSPATR(&A1STS) To archieve this I wrote two functions. For the first one I can pass the display attributes as I'd specify them in DDS, for example 'YLW': 'UL' and return the appropriate hex value. The valid hex values are x'20' to x'3F' for unprotected display attributes and x'A0' to x'BF' for protected display attributes. Instead of handling different situations with switching different indicators Off and On I simply determine the hex value in my program: Example: /Free Select When Action = Display and R1Sts = Active; A1Sts = SetDspAttr('WHT': 'PR'); When Action = Display and R1Sts = Inactive; A1Sts = SetDspAttr('RED': 'PR'); When Action <> Display and R1Sts = Active and R1Date <= %Date(); A1Sts = SetDspAttr('YLW': 'UL'); When Action <> Display and R1Sts = Active and R1Date > %Date(); A1Sts = SetDspAttr('TRQ': 'UL'); When Action <> Display and R1Sts = Inactive; A1Sts = SetDspAttr('RED': 'PR'); EndSl; /End-Free The other function I've written returns the reverse image for a given display attribute in hex. In this way I easily can change the display attribute without taking care about the conditions I set before. Example: /Free Monitor; ChkFkt(R1Sts); On-Error; A1Sts = SetDspAttrRI(A1Sts); SetCsrPos(R1Row: R1Col: 'DSPF': 'FORMAT': 'FIELD'); EndMon; /End-Free
A little more trickier is to position the cursor to a specified field without hardcoding column and row, because the API QDFRTVRD (Retrieve Display File Description) must be used. But a prodecure, written once and tested, will work forever. The only thing for what I have to use indicators, is for subfiles. There is no workaround to avoid indicators in DDS. Birgitta