Computer Science Canada

arrays initialization

Author:  timtimpei [ Tue Jan 15, 2008 4:45 pm ]
Post subject:  arrays initialization

k i need to initialize all my array variables the same thing, so

var num: array 1..70 of boolean := init (false, false, false,.....)

sigh... how do i make this easier?

Author:  StealthArcher [ Tue Jan 15, 2008 5:01 pm ]
Post subject:  Re: arrays initialization

For loops my friend, they are wondrous beings.
Oh and if you are making what I think you are having a constant would be good also.

code:

const numberofthings:int:=70
var chars:array 1..numberofthings of boolean
for v: 1..numberofthings
     chars(v):=false
end for


There, simple for loop initialization, make something similar for all other arrays that need it. Any other questions?

Author:  timtimpei [ Tue Jan 15, 2008 5:05 pm ]
Post subject:  RE:arrays initialization

thx a lot

Author:  StealthArcher [ Tue Jan 15, 2008 5:06 pm ]
Post subject:  RE:arrays initialization

No problem, always glad to help those willing to learn.

Author:  ericfourfour [ Tue Jan 15, 2008 5:07 pm ]
Post subject:  RE:arrays initialization

Or if you don't know the upper or lower bound of the array:

upper (chars)
lower (chars)

Author:  StealthArcher [ Tue Jan 15, 2008 5:08 pm ]
Post subject:  Re: arrays initialization

I assumed he did so I left it out, but anyhow, it's probably good for him to know.


: