tags:

views:

236

answers:

2

When I want an integer in an RPGLE program, what data type should I choose? I'm talking about an integer that doesn't correspond to any field in the database, just a normal general purpose integer - kind of the equivalent of an int in Java.

A: 

You can use the binary (signed integer) (B) or integer (unsigned integer) (I) types. You can specify the size with the digit values of 3 (1 byte), 5 (2 bytes), 10 (4 bytes) or 20 (8 bytes). The equivalent of a Java int would be 10B.

Paul Morgan
+2  A: 

Here's a chart from the ILE RPG Programmer's reference guide:

byte -  3I 0  (1-byte integer)
short-  5I 0  (2-byte integer)
int  - 10I 0  (4-byte integer)
long - 20I 0  (8-byte integer)

I use the 10I 0 form of integer most often. You'll find it's used in most of your API calls as well.

Tracy Probst