Computer Science Canada

Flexible Array Help

Author:  mike200015 [ Fri Feb 25, 2005 10:12 pm ]
Post subject:  Flexible Array Help

I have a flexible array of int, Can you set all of the vars with in the array to (0) at the begining, and when a new upper bound is added, that will be set to zero, but not reset all vars to zero Question

Author:  AsianSensation [ Fri Feb 25, 2005 10:36 pm ]
Post subject: 

just keep track of the size of your old array, I think by using upper?

code:
var num : flexible array 1 .. 5 of int
var oldSize : int

for rep : 1 .. upper (num)
    num (rep) := 0
end for

oldSize := upper (num)

new num, 25

for rep : oldSize .. upper (num)
    num (rep) := 0
end for


: