01-17-2005, 07:26 PM
Rel: you can use STATIC with arrays too, they are allowed with FB, will work.
Z!re: the "right" way would be:
at module level.
and at proc level.
That's how it's done in QB.. a DIM SHARED inside a function will open it to memory leaks as that array is "impossible" to erase implicitly or explicitly in other routines later. When you create a dynamic *local* array inside a proc the compiler will erase them automagically when the proc finish - if you are DIM'ing a shared array that won't be done, it's up the the user to call ERASE at a shutdown() proc or such.
Code:
static array(1000) as integer
Z!re: the "right" way would be:
Code:
dim shared myarray() as mytype
and
Code:
redim myarray(...) as mytype
That's how it's done in QB.. a DIM SHARED inside a function will open it to memory leaks as that array is "impossible" to erase implicitly or explicitly in other routines later. When you create a dynamic *local* array inside a proc the compiler will erase them automagically when the proc finish - if you are DIM'ing a shared array that won't be done, it's up the the user to call ERASE at a shutdown() proc or such.
ew FreeBASIC forums: http://www.freebasic.net/forum/index.php