aikidaves
I personally don\'t care for the True/False thing, since you\'re just renaming *On and *Off, which IBM has already provided for us. Since there\'s no need for them in comparisons anyway (why say \'if Record_Found = True\' when \'if Record_Found\' or its inverse \'if not Record_Found\' are just as clear), the only time to use True/False or *On/*Off is when setting values. Are *On and *Off that hard to understand? Just my preference, of course.
D.Eckersley
So I\'m not the only one who uses TRUE and FALSE constants. I actually have a copybook that I put into each and every program I write. It has the SDS, TRUE, FALSE, and some other constants like UCase, LCase, Apost, Numeric, OK, and some fields like SysDate, JobDate, etc. I also have a copybook for my display work, which forces me to standardize my indicators (ie, the 90s are for subfile control, etc), contains constants for working with the AID byte (which can also be used to capture mouse events, by the way), constants for display attributes,etc. The one drawback to an INDDS data structure that I don\'t like, however, is that you can only put in N fields, or arrays of N fields. I sometimes like to group certain indicators together into one field, so I can do code like SflAction = SflClear or inErrors = *all\'0\' You can\'t group indicators like that in an INDDS, [i>but[/i>, you can overlay another DS over the INDDS. I have a pointer initialized to the address of the INDDS, and I use it to overlay other DSs, defined however I like, over the INDDS. I have a standard one in my copybook, and I usually define one separately in each program, where I can set up named indicators specific to the program. I don\'t have a point here, other than to say I agree and to ramble.
jeff_olen@hotmail.com
The whole TRUE/FALSE thing is my preference. There are two reasons for this. First, the code is easier to read. This is particularly in the case of errors on displays (an in the example from the article). Sometimes if the variables you are using are named particularly well then using *ON and *OFF can read well too. But usually that\'s not the case. Secondly, TRUE and FALSE are commonly used in other languages (C++, PHP and Java for example). But as with most things about language syntax...ultimately its a matter of preference. Thanks for the feedback. Jeff
[size="1">Code[/size>
jeff_olen@hotmail.com
I am ok with the rambling...especially since I do it too. Although it\'s always easier to endure it when the person doing the rambling is busy agreeing with me. ;-) The overlaying of the INDDS is a good idea. Saves time and trouble re-initializing stuff. Thanks, Jeff
Chipper2
Another option to get rid of indicators in programs is to use program to system fields (P-fields). This also requires creating hex values (similar to defining the F-Keys). I tried to find my handout from Charlie Massoglia, but couldn\'t. Let me try to see if I have a copy at home.
Guest.Visitor
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
jeff_olen@hotmail.com
Chipper, You and Birgitta are both correct about the P-fields. They can be used in place of indicators in DDS. The one draw back is that there is not a way to use the P-fields to position the cursor. So you are stuck with using indicators for that. Also, as Birgitta points out, you cannot use the P-fields to condition subfile keywords. P-fields have an additional draw back of requiring a fair amount of changes to both the RPG source and the DDS source when modifying an existing program. With that said, the P-fields are a excellent tool to reduce use of indicators in new development. Thanks for your comments. :-) Jeff
jeff_olen@hotmail.com
Birgitta, What I have found is that removing indicators from existing DDS source is most often more trouble than it is worth. Also, as you point out, using P-fields cannot eliminate indicators completely. As I said in my response to Chipper2, P-fields are a great solution for new development. Not so much for updating existing stuff. Thanks for the great description and code example. :-) Jeff
Barbara Morris
DougCMH wrote: > > The one drawback to an INDDS data structure that I don\'t like, > however, is that you can only put in N fields, or arrays of N fields. > I sometimes like to group certain indicators together into one field, > so I can do code like SflAction = SflClear or inErrors = *all\'0\' You > can\'t group indicators like that in an INDDS, ... You _can_ group indicators in the INDDS. You can define A-type subfields, and you can define subfields with no type or length that are defined by the other subfields that are overlaid on them. D indds ds D errInds overlay(indds:31) D nameErr n overlay(errInds:1) D amtErr n overlay(errInds:2) D dateErr n overlay(errInds:3) D showInds 10a overlay(indds:51) D showErrmsg n overlay(showInds:1) D showTotal n overlay(showInds:2) But I\'m not sure that using overlay this way is very good; it\'s not particularly easy to see that amtErr matches indicator 32 in the DDS. Here is another way to define it that may be more clear. It doesn\'t explicitly overlay the grouped subfields over the group subfield, but the indentation shows the grouping. D indds ds D errInds 3 overlay(indds:31) D nameErr n overlay(indds:31) D amtErr n overlay(indds:32) D dateErr n overlay(indds:33) D showInds 10 overlay(indds:51) D showErrmsg n overlay(indds:51) D showTotal n overlay(indds:52)
jeff_olen@hotmail.com
Barbara, I think the second snippet of code is the clearer way of coding it (see code below). When it is coded that way it is much easier to decipher which variable corresponds to which indicator. thanks, Jeff
[size="1">Code[/size>
Barbara Morris
Oops, sorry about my previous message. I posted it from a newsreader, forgetting that it would get garbled on the website. Jeff, in my original example, I had the xxxErr subfields indented one more level inside errInds. I think it\'s important to show visually that the xxxErr subfields are contained within errInds. Your comment lines do a good job of showing the related fields, but I think indentation is also useful.
[size="1">Code[/size>
jeff_olen@hotmail.com
Barbara, You are right. The indentation does make it more obvious what is being done. Nice work. :-) Thanks, Jeff
D.Eckersley
I pulled this from the RPG Reference on the V5R4 InfoCenter: Indicator Data Structure An indicator data structure is identified by the keyword INDDS on the file description specifications. It is used to store conditioning and response indicators passed to and from data management for a file. By default, the indicator data structure is initialized to all zeros (\'0\'s). The rules for defining the data structure are:
    [*>It must not be externally described. [*>[i>It can only have fields of indicator format.[/i> [*>It can be defined as a multiple occurrence data structure. [*>%SIZE for the data structure will return 99. For a multiple occurrence data structure, %SIZE(ds:*ALL) will return a multiple of 99. If a length is specified, it must be 99. [*>[i>Subfields may contain arrays of indicators as long as the total length does not exceed 99.[/i> [/list> If your code compiles and works, then either I\'m not understanding that part in italics above, or, the documentation is lying again. If the latter, maybe I [i>can[/i> use a left-side %subdt.
Steve.Kiferd
I use the indicator ds to eliminate them in rpg programs. However using program to display fields to eliminate the indicators in dds seems like overkill to me and would make maintenance of these processes more difficult for the next person. Sometimes the KISS principle does make sense. just my .02
Guest.Visitor
Hi, it was already difficult to handle the following display file. But then I had to add an additional indicator, to handle an other exception.
 A R1TNR R B 8 33REFFLD(TNR LLREFDP) A TEXT(\'Artikel-Nr.\') A 12 DSPATR(RI) A N80 60N82 DSPATR(UL) A 80 AON60 AO 82 DSPATR(PR) A 12 DSPATR(PC) A N80 60N82 COLOR(YLW) A 80 AON60 AO 82 COLOR(WHT) A 83 R1LAB R B 19 33REFFLD(LAB LLREFDP) A TEXT(\'Lagerort\') A 20 DSPATR(RI) A N80 60 DSPATR(UL) A 20 DSPATR(PC) A 80 AON83 AON60 DSPATR(PR) A N80 60 83 COLOR(TRQ) A N80 60N83 COLOR(YLW) A 80 AON60 COLOR(WHT) A 83 R1LBE R O 19 38REFFLD(LBE LLREFDP) A TEXT(\'Bezeichnung Lagerort\') A COLOR(WHT) 
The following snippet not only looks much easier, but its much easier to handle the different situations in the RPG program (where setting paranthesis is allowed).
 A A1TNR 1A P TEXT(\'Display-Attribute für – A Artikel-Nr.\') A A1LAB 1A P TEXT(\'Display-Attribute für Lager\') A R1TX11 30 O 6 2TEXT(\'Artikel-Nr.\') A MSGID(FTX 0503 LLMSGF) A R1TNR R B 6 33REFFLD(TNR LLREFDP) A TEXT(\'Artikel-Nr.\') A DSPATR(&A1TNR) A R1TX13 30 O 19 2TEXT(\'Lagerort\') A MSGID(FTX 4668 LLMSGF) A R1LAB R B 19 33REFFLD(LAB LLREFDP) A TEXT(\'Lagerort\') A DSPATR(&A1LAB) 
Birgitta
jeff_olen@hotmail.com
The documentation is not terrible clear and possibly just wrong. Both versions of the code I have attached below compile correctly and function as you would expect. Also, I have attached the link to the RPG ILE reference for V5R4. Check out the INDDS rules. RPG ILE V5R4 reference Good luck, Jeff
[size="1">Code[/size>
Barbara Morris
DougCMH wrote: > I pulled this from the RPG Reference on the V5R4 InfoCenter: > > Indicator Data Structure > ... > * It can only have fields of indicator format. ... Oops. The compiler is right, the manual is wrong.
J.Pluta
Isn\'t that always the case, Barbara? Joe
Barbara Morris
Joe Pluta wrote: > Isn\'t that always the case, Barbara? > > > Yep, pretty much. My software engineering professor said that as soon as a product is in the hands of a user, the only valid specification for that product is the product itself. But in this particular case, it wasn\'t an accidental bug-turned-feature. It was a deliberate decision to support both character and indicator subfields for INDDS.
tstephens55
I also will set up variables valid/notvalid, etc. It makes the code much more readable as I would rather see "If pTestAddr = Valid" then "If pTestAddr = *on". (pTestAddr refering to a procedure that returns an indicator variable).
J.Pluta
Which is why I prefer to use completely meaningful names like TestAddressIsValid. Then I can just say "If TestAddressIsValid". By using the name of the Boolean to completely describe the *ON condition, you can avoid having to do any comparison at all. Joe
jeff_olen@hotmail.com
I name my procedures with names like isValidCustomer. So except for my dyslexia the meaning is all in the name. ;-) Jeff
J.Pluta
And actually that\'s the standard for the OO world. If you have a boolean, the getter for the boolean is normally isVariableName. Thus you name your booleans to indicate the condition name. For example, I might have a boolean named numeric for a field, and then I can write "if field.isNumeric()". That\'s pretty self-documenting. And you could do that with a qualified data structrue just as easily if you name the fields with the "is" prefix. If you have a data structure named Customer with an indicator named isOnCreditHold, you could write "if Customer.isOnCreditHold;". Joe
Please login to make comments.
User Rating: / 0
PoorBest 

WHITE PAPERS

The following White Papers can be found at the MC White Paper Center

 

 


   MC-STORE.COM