We help IT Professionals succeed at work.

# Array defining in RPG

on
682 Views
Hi,

Could somebody tell me how to define Array in RPG IV and initialize it as per the below example

I have a example in "C" and I want to define it in RPG

int xyz[15];
xyz[0] = 1;
xyz[1] = 0;
xyz[2] = 1;
xyz[3] = 1;
xyz[4] = 0;
xyz[5] = 1;
xyz[6] = 1;
xyz[7] = 1;
xyz[8] = 93;
xyz[9] = 90;
xyz[10] = 95;
xyz[11] = 95;
xyz[12] = 5;
xyz[13] = 0;
xyz[14] = 0;

Comment
Watch Question

## View Solution Only

Commented:
Hi
In ILE you would do
Dxyz              S              5S 0 DIM(15) CTDATA
C                   EVAL      *INLR=*ON
C
C
C
** COMPILE DATA FOR XYZ
00001
00000
00001
00001
00000
00001
00001
00001
00093
00090
00095
00095
00005
00000
00000

Commented:
and in RPG
E                    XYZ     1  15  5 0
C                     SETON                     LR
C                     CLEARXYZ
** COMPILE DATA FOR XYZ
00001
00000
00001
00001
00000
00001
00001
00001
00093
00090
00095
00095
00005
00000
00000

Commented:
ps
in RPG we do not have element (0) we start at 1

Commented:
Hi Dave,

What line the compile data start from. Since I am getting copiling errors.

*RNF0257 30     15 Form-Type entry for main procedure not valid or out of
sequence.

Can you please what is it.

Regards,

Dhumal

Commented:
This section should be start in Col 6
Dxyz              S              5S 0 DIM(15) CTDATA
C                   EVAL      *INLR=*ON
C
C
C

This section should start in Col 1. in SEU you must use F17 to shift to col 1 when using RPGLE. That will be the problem.

** COMPILE DATA FOR XYZ
00001
00000
00001
00001
00000
00001
00001
00001
00093
00090
00095
00095
00005
00000
00000

dave

Commented:
Sorry
that shoudl be F19 (Shift F7) to move left

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)

Commented:
Thanks, Dave. It worked fine after shifting the values on left.

Unlock the solution to this question.

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.