MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Move array values into a variable

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
suryavd
Beginner


Joined: 07 Feb 2006
Posts: 2
Topics: 1

PostPosted: Tue Feb 07, 2006 10:54 am    Post subject: Move array values into a variable Reply with quote

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
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Feb 08, 2006 5:33 am    Post subject: Reply with quote

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
View user's profile Send private message
suryavd
Beginner


Joined: 07 Feb 2006
Posts: 2
Topics: 1

PostPosted: Wed Feb 08, 2006 9:27 am    Post subject: Thank you Reply with quote

Thank you Mervyn. I tried the first and last approaches. both of them worked. Thanks a lot.

Regards,
Surya.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group