IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how can we Declare DYNAMIC ARRAy in PL/1?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ARIVUMR

New User


Joined: 21 Apr 2006
Posts: 11
Location: Chennai

PostPosted: Mon Apr 24, 2006 1:58 pm
Reply with quote

hi
can anyone tell me what is Dynamic array? how can we declare in PL/1?

if possile give me example.


Thanks and Regards
haris
Back to top
View user's profile Send private message
MSMITHUK

New User


Joined: 31 Mar 2005
Posts: 5
Location: London

PostPosted: Mon Apr 24, 2006 9:12 pm
Reply with quote

Hi,

I am not sure if this is the answer you are looking for but there is an option called REFER which can be used on arrays that allows variables for the size of the array.
I have included the page from the Language Reference, hope it helps

===========================================
A self-defining structure or union contains information about its own fields, such as the length of a string. A based structure or union can be declared to manipulate this data. String lengths, array bounds, and area sizes can all be defined by variables, known as the refer object, declared within the structure or union. When the structure or union is allocated (by either an ALLOCATE statement or a LOCATE statement), the value of an expression is assigned to the refer object variable. For any other reference to the structure or union, the value of the refer object is used.

The REFER option is used in the declaration of a based structure or union to specify that, on allocation of the structure or union, the value of an expression is assigned to the refer object and represents the length, bound, or size of another variable in the structure or union. The syntax for a length, bound, or size with a REFER option is shown in the following diagram.

Regards,
Moira



________________________________________________________________________
| |
| >>__expression__REFER__(member-variable)____________________________>< |
| |
|________________________________________________________________________|



expression The value of this expression defines the length, bound, or size of the member when the structure or union is allocated (using ALLOCATE or LOCATE). The expression is evaluated and converted to FIXED BINARY (31,0). Any variables used as operands in the expression must not belong to the structure or union containing the REFER option.
Back to top
View user's profile Send private message
ARIVUMR

New User


Joined: 21 Apr 2006
Posts: 11
Location: Chennai

PostPosted: Tue Apr 25, 2006 11:01 am
Reply with quote

Thank u moria , i will go through it .

regards
hari
Back to top
View user's profile Send private message
vish75

New User


Joined: 11 Jan 2006
Posts: 1
Location: kol

PostPosted: Wed Apr 26, 2006 5:10 pm
Reply with quote

I have used another method in which i needed an array whose size is being defined dynamically. look at the sample code below. It might help you..

dcl CONTENTLENGTH fixed bin(31);
dcl wparam char(*) ctl;

CONTENTLENGTH = 500; /* or any value depending on program logic */

if allocn(wparam) = 1 then free wparam;

allocate wparam char(CONTENTLENGTH);

wparam = teststrg; /* test strg may be a char string */

p.s - pls correct me if i m wrong.

regards vishy
Back to top
View user's profile Send private message
ARIVUMR

New User


Joined: 21 Apr 2006
Posts: 11
Location: Chennai

PostPosted: Fri Apr 28, 2006 11:53 am
Reply with quote

hi vishy ,

Thank u , i am aking about dynamic array i think u have mentioned vaiable length character string whcih is dynamically created. i need dynamic ARRAY .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts Dynamic file allocation using JCL JCL & VSAM 8
Search our Forums:

Back to Top