Hello!
How come REDIM on a static array inside a function does not work.
UBOUND always returns the same amount as the first redim. If this
is not allowed then why doesn't ERR return an error?
first "summary(%SETSIZE,100,0)" works and sets array to 100 elements.
second "summary(%SETSIZE,50,0)" leaves the array at 100 elements?
------------------
Cheers
How come REDIM on a static array inside a function does not work.
UBOUND always returns the same amount as the first redim. If this
is not allowed then why doesn't ERR return an error?
first "summary(%SETSIZE,100,0)" works and sets array to 100 elements.
second "summary(%SETSIZE,50,0)" leaves the array at 100 elements?
Code:
#compile exe %SETSIZE = 1 %GETSIZE = 2 %GETRECORD = 3 %PUTRECORD = 4 function Summary(byval message as long,byval wparam as long,byval lparam as long) as long static Cache() as long select case (message) case %SETSIZE redim preserve Cache(wParam) function = err case %GETSIZE function = ubound(Cache) case %GETRECORD function = Cache(wParam) case %PUTRECORD Cache(wParam) = lParam end select end function function pbmain as long msgbox str$(summary(%SETSIZE,100,0)) msgbox str$(summary(%GETSIZE,0,0)) msgbox str$(summary(%SETSIZE,50,0)) msgbox str$(summary(%GETSIZE,0,0)) msgbox str$(summary(%PUTRECORD,8,256)) msgbox str$(summary(%GETRECORD,8,0)) end function
Cheers
Comment