joelcochran
I\'d like to start by saying I don\'t disagree with anything in your article: the examples you provide could easily cause problems, but that is exactly why I felt the need to respond. All of the issues listed are predicated on coding practices that, at least based on what\'s available today in RPGIV, could be replaced with alternative (and arguably superior) methods. I\'d like to offer some alternatives that would assist in resolving these issues for any of your readers. Consider this code from the article: d BinaryFld1 s 9b 0 inz(10)
*like define BinaryFld1 BinaryFld2
eval BinaryFld2 = BinaryFld1
First, you should use the Integer data type instead of Binary: this data type is a "real" integer. Second, using *like...define... should be replaced with another "D" spec (where as a matter of practice all variables should be defined anyway) at which point you can still use "like", so the code would look liek so: d BinaryFld1 s 10i 0 inz(10) d BinaryFld2 s like(BinaryFld1) inz
eval BinaryFld2 = BinaryFld1
"9b 0" and "10i 0" are interchangeable for API calls and such. I think these two changes would correct that problem. On the MOVE topics, my gut response is to replace move. This issue has been hashed to death on the discussion boards and has reached something of a "holy war" status, so I\'m not going to impugn the use of MOVE, merely point out that a non-MOVE solution to this problem would help.
eval Signed5a = %int( %subst( Char10a) )
eval Signed5b = %int( %subst( Char10b) )
This would be for V5R2: for V5R1 you would need some character to numeric converter, such as "atoi" or one of the many freely published procedures. I guess the point is that these newer approaches are designed to be more explicit and would thereby help tremendously. Does that help when maintaining 10 million lines of already existing code? Of course not, just something to keep in mind for new development. Joel Cochran http://www.rpgnext.com
gotto@islandpacific.com
I have found a similar issue with fields defined as signed. A file has a field defined as signed, I have a D-spec (or C-spec) *like/define statement defining a new field "based on" the file\'s field. Instead of getting a second field defined as signed, I get a packed field instead. To get around this I had to get the file\'s field "brought into" the program as a subfield of a data structure (so it would retain it\'s definition as signed). I found the following in the RPG manual: "Note the following for *LIKE DEFINE of numeric fields: - If the field is fully defined on Definition Specifications, the format is not changed by the *LIKE DEFINE. - Otherwise, if the field is a subfield of a data structure, it is defined in zoned format. - Otherwise, the field is defined in packed format." So, because originally the field from the file was NOT in a data structure it was defined as packed. Once I included it in an externally defined data structure, it retained it\'s signed definition. Garrett Otto
Guest.Visitor
Joel, All excellent points. Jeff
Guest.Visitor
The link to the RPG reference information regarding binary fields should be http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c092508415.htm#HDRBINAFOR Sorry for the confusion. Jeff
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