declare size of extent at run time

shafee212

Member
I want to declare extent size of a variable at run time
for eg

i am updating a variable n (integer) at run time . i want to declare a variable var of type character and extent with size equal to n .

This can alos be termed as dynamic variable declaration .
 
it is in some way possible:
Code:
run setExtent(input 3,'a,b,c').
 
procedure setExtent:
DEFINE INPUT  PARAMETER iExtent AS INTEGER     NO-UNDO.
DEFINE INPUT  PARAMETER cpValues AS CHARACTER   NO-UNDO.
DEFINE VARIABLE iTmp AS INTEGER     NO-UNDO.
DEFINE VARIABLE cExtent AS CHARACTER extent  NO-UNDO.
 
assign extent(cExtent) = iExtent.
do iTmp = 1 to iExtent:
    assign cExtent[iExtent] = entry(iTmp,cpvalues).
end.
       
end procedure.

Depending on your needs this may help ;-)

regards,

Casper.
 
Hi,
I think i version 10 has a facility of dynamic array.
DEFINE VARIABLE i-lint AS INTEGER EXTENT NO-UNDO.
EXTENT(i-lint) = 3.
ASSIGN
i-lint[1] = 6
i-lint[2] = 7
i-lint[3] = 8.
DISP i-lint[1] i-lint[2] i-lint[3].

You can put this n value instead of that 3 I put. Hope this will help.
Regards
Philip P Oommen
 
DEFINE VARIABLE cExtent AS CHARACTER extent NO-UNDO.

This thing is not working . It is saying that extent should be followed by INTEGER CONSTANT .
 
Let me know the version of Progress you are working. In 10.1B following code is working fine .

DEFINE VARIABLE i-lint AS CHARACTER EXTENT NO-UNDO.
EXTENT(i-lint) = 3.
ASSIGN
i-lint[1] = "a"
i-lint[2] = "b"
i-lint[3] = "c".
DISP i-lint[1] i-lint[2] i-lint[3].

Regards
Philip P Oommen
 
Back
Top