View previous topic :: View next topic
|
Author |
Message |
raviputran
New User
Joined: 05 Jul 2007 Posts: 13 Location: bangalore
|
|
|
|
Hi all,
Is it allowed in PL/I?
DECLARE ARRAY_A(10) PIC '(4)X';
DECLARE P POINTER;
DECLARE ARRAY_B(10) PIC '(4)9' BASED(P);
P = ADDR(ARRAY_A);
I used this and found ARRAY_B is not having any values.
Thanks in advance. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
This is allowed in PL/1 ... but here your ARRAY_A does not have any value then how will it get reflected in ARRAY_B ? |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Lest it jump up to bite some day, it's better to be more specific in overlay of arrays:
is not as safe as
Code: |
P = ADDR(ARRAY_A(1)); |
Otherwise, code optimization may result in incorrect positioning.
Regards,
Garry. |
|
Back to top |
|
|
raviputran
New User
Joined: 05 Jul 2007 Posts: 13 Location: bangalore
|
|
|
|
Hi all,
Thanks for the response. I got that solved.
Problem:
DECLARE ARRAY_A(10) PIC '(4)X';
DECLARE P POINTER;
DECLARE ARRAY_B(10) PIC '(4)9' BASED(P);
P = ADDR(ARRAY_A);
I was passing values to ARRAY_A based on some condition. However it
was not getting reflected in ARRAY_B. I just used another pointer to point
the alphanumeric to char and pointed that char to numeric. Then it went right.
DECLARE ARRAY_A(10) PIC '(4)X';
DECLARE ARRAY_B(10) CHAR(04) BASED(P);
DECLARE ARRAY_C(10) PIC '(4)9' BASED(Q);
DECLARE P POINTER;
P = ADDR(ARRAY_A);
DECLARE Q POINTER;
Q= ADDR(ARRAY_B);
Now the changes I made in ARRAY_A got reflected in ARRAY_C which was
my requirement. |
|
Back to top |
|
|
|