View previous topic :: View next topic |
Author |
Message |
suryavd Beginner
Joined: 07 Feb 2006 Posts: 2 Topics: 1
|
Posted: Tue Feb 07, 2006 10:54 am Post subject: Move array values into a variable |
|
|
Hi,
I need to move the contents of an array into a character variable whose declarations are as below:
DCL VAR1 CHAR(4) INIT('ABCD');
DCL TARRAY(4) CHAR(1) INIT ('E','F','G','H');
now in one step, i want to move 'efgh' into var1.
I tried as VAR1 = TARRAY; but this is giving compilation error.
Even VAR1= TARRAY(*) also did not work.
Can any one please help me in this?
Regards,
Surya. |
|
Back to top |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed Feb 08, 2006 5:33 am Post subject: |
|
|
Try one of these:
Code: | VAR1 = STRING(TARRAY);
VAR1 = TARRAY(1)||TARRAY(2)||TARRAY(3)||TARRAY(4);
DCL VAR2 CHAR(4) BASED(ADDR(TARRAY(1));
VAR1 = VAR2; |
_________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
 |
suryavd Beginner
Joined: 07 Feb 2006 Posts: 2 Topics: 1
|
Posted: Wed Feb 08, 2006 9:27 am Post subject: Thank you |
|
|
Thank you Mervyn. I tried the first and last approaches. both of them worked. Thanks a lot.
Regards,
Surya. |
|
Back to top |
|
 |
|
|