View previous topic :: View next topic
|
Author |
Message |
ARIVUMR
New User
Joined: 21 Apr 2006 Posts: 11 Location: Chennai
|
|
|
|
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 |
|
|
MSMITHUK
New User
Joined: 31 Mar 2005 Posts: 5 Location: London
|
|
|
|
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 |
|
|
ARIVUMR
New User
Joined: 21 Apr 2006 Posts: 11 Location: Chennai
|
|
|
|
Thank u moria , i will go through it .
regards
hari |
|
Back to top |
|
|
vish75
New User
Joined: 11 Jan 2006 Posts: 1 Location: kol
|
|
|
|
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 |
|
|
ARIVUMR
New User
Joined: 21 Apr 2006 Posts: 11 Location: Chennai
|
|
|
|
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 |
|
|
|