Avatar of hardrock95
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.
IBM System i

Avatar of undefined
Last Comment
Member_2_276102

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gary Patterson, CISSP

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
hardrock95

ASKER
Thanks, Any idea what I may be doing wrong since I cannot find information in this same manual?  Big help today. Thanks again.
Member_2_276102

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
Gary Patterson, CISSP

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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Member_2_276102

@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