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



Tony wrote:

> I have a display file that contains, for each input field, an
indicator-line
> that reverse-images the field.  This indicator is turned on by the program
> if the data in that field is invalid.  Before I step into my
error-checking
> SR, I want to turn off all of these indicators.

Others have given good advice on how to shorten the code.  I would not
personally equate fewer lines of code with 'better'.  In fact, I rather like
your existing method.  With the addition of right hand comments, it would be
exceedingly clear what the intent of the code is.  With that in mind, you
can use Scott's example of named indicators, and instead of setoff 95 you
would use eval descriptionHilight = *off.  This is very clear and the
maintenance programmer who follows you (it might even be you, a year from
now!) should have no trouble understanding what you mean to do.

There is another technique which might interest you, and that is the DDS
keyword DSPATR() used with a program to system field.  Instead of
communicating with the display file via indicators, you can set the
attributes directly - multiple attributes for the same field if need be.
This can reduce indicator usage while improving the readibility of the code.
It's a style question whether one feels that eval descriptionHilight = *off
is nicer than eval descAttr = setAttr(NORMAL).  The downside of this
technique is the 10 character field name restriction in DDS.

A                                      CF03(03 'Exit')
A*
A          R DSPFR                     TEXT('Display file examples')
A                                      BLINK
A*
A                                  9  2'Some input'
A                                      DSPATR(HI UL)
A            FLDA          10   B 10  2TEXT('Generic input/output')
A                                      DSPATR(&FLDAATR)
A            FLDB          20   B 11  2TEXT('Generic input/output')
A                                      DSPATR(&FLDBATR)
A            FLDAATR        1   P
A            FLDBATR        1   P

*************** Beginning of data
*************************************************
H debug option(*srcstmt: *nodebugio)
H actgrp('QILE') dftactgrp(*no)
 * dbgview(*list)

 * Show use of program to system attribute field

fdspfatr   cf   e             workstn

 * work variables
d atr             s                   like(fldaatr)

 * field attribute bit patterns
d NO              s              1a   inz(x'00')
no attrs
d RI              s              1a   inz(x'01')
reverse
d HI              s              1a   inz(x'02')
highlight
d UL              s              1a   inz(x'04')
underline
d ND              s              1a   inz(x'07')
non display
d BL              s              1a   inz(x'08')
blink
d NP              s              1a   inz(x'20')
non protect
d CS              s              1a   inz(x'30')
column sep
d PR              s              1a   inz(x'80')
protect

d setAtr          pr                  like(atr)
d  inpFld                       50    const

c                   dow       *in03 = *off
c                   exfmt     dspfr
c   03              leave
c                   exsr      processDSPF
c                   enddo

c                   eval      *inLR = *On

 * ===========================================================
c     processDSPF   begsr

 * Top field to specify the colour of the bottom field, vice versa
c                   eval      FLDAATR = setAtr(FLDB)
c                   eval      FLDBATR = setAtr(FLDA)
c                   endsr

 * ===========================================================
p setAtr          b
d setAtr          pi                  like(atr)
d  inpFld                       50    const

d atrWork         s                   like(atr)

 * reset all attributes
c                   eval      atrWork = NP

c                   select
c                   when      inpFld = 'RI'
c                   biton     RI            atrWork
c                   when      inpFld = 'HI'
c                   biton     HI            atrWork
c                   when      inpFld = 'UL'
c                   biton     UL            atrWork
c                   when      inpFld = 'BL'
c                   biton     BL            atrWork
c                   when      inpFld = 'CS'
c                   biton     CS            atrWork
c                   endsl

c                   return    atrWork

 p                 e

  --buck




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.