Is it possible to use a variable as an array extent.

xscottehx

Member
I am wanting to use a variable to store the size of the extent for an array.

for example:

DEF VAR itimes AS INT NO-UNDO EXTENT iextsize.(this won't work)

I am trying to store an array of time values and on the main procedure users can add bookings that increase the number of times that have to be stored so the size of the array will differ. At the moment i am just using a hard coded large number that i think will cope with the varying extent size but feel this is wasteful of resources.

Thanks.
 

Cringer

ProgressTalk.com Moderator
Staff member
Version 10 has variable extents, but I believe they can't be reset once they have been initialised to a value. The only truly dynamic way I know of for this sort of thing would be a simple temp-table with a key field (integers 1 - n) and a value field.
 

lord_icon

Member
Lets think about what you are asking:
At compile time,
I want to create an array with the value of a variable I have just created and therefore don't know the value of until run time.
Head scratching, how can I / Progress / OpenEdge do that??
At compile time I need to have constants.
 

lord_icon

Member
Greetings,

Now that we know we cant use a variable value.
A work around would be to use a value that is not going to be reached.
Leaving something in your pocket for the unknown.
Therefore at compile time I have a constant value - I know it will not reach 50 for how it is used so at compile time I will assign the value to be 50.

Then at runtime, I can use appropriate algorithms using variable values.
 

tamhas

ProgressTalk.com Sponsor
And yet, that is exactly what the dynamic arrays provide. I.e., the size must be known before use, but not before that.
 

Casper

ProgressTalk.com Moderator
Staff member
Now that we know we cant use a variable value.

Like Thomas said: we can:

Code:
RUN fillextent (INPUT 3).
RUN fillextent (INPUT 4).
RUN fillextent (INPUT 5).
 
PROCEDURE fillextent:
DEFINE INPUT  PARAMETER iLength AS INTEGER     NO-UNDO.
DEFINE VARIABLE iExtent  AS INTEGER  EXTENT   NO-UNDO.
DEFINE VARIABLE iTmp AS INTEGER     NO-UNDO.
ASSIGN EXTENT(iExtent) = iLength.
DO iTmp = 1 TO iLength:
    iExtent[iTmp] = iTmp.
END.
MESSAGE EXTENT(iExtent)
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
END PROCEDURE.

Casper.
 
Top