Link to home
Create AccountLog in
Avatar of hardrock95

asked on

Define binary variable in RPG free d specs

It is my understanding that below is how you define a binary variable of length 2 in rpg IV D specs.  How do you make the same definition in RPG FREE D SPECS?  

D variableName              S       5i 0

As always thanks ahead for any help.
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of hardrock95


Thanks, Any idea what I may be doing wrong since I cannot find information in this same manual?  Big help today. Thanks again.
The link that Gary provided goes directly to the information. It's not clear how it's possible that you "cannot find" it. Just click the link. When it opens, the navigation pane on the left shows how to locate the information.

However, you almost certainly do not want to use a BINDEC() variable. Those are not exactly equivalent to the fixed-form "5i 0" that you showed in your question. BINDEC() variables would be the equivalent to the old "B" data type that really should never be used unless you are certain you really need it.

Instead, you most likely want the Integer Format. The specification is described in the INT(digits) topic. The example in the documentation shows a maximum 10-digit integer. Your question asks about a 5-digit integer, so you would use:
DCL-S variableName INT(5);

Open in new window

That's about all there is to it.

Tom's exactly right, of course.  Not sure how I got it in my head that you were looking for "B" type when the question directly asks for "I".  Sorry about the confusion.

Thanks, Tom.
@Gary: No problem. BINDEC() would probably work, but you never know when a future code change could bring a lot of confusion for some maintainer who didn't know what the "B" data type really was, eh?. -- Tom