Announcement

Collapse
No announcement yet.

I need advise on this one...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I need advise on this one...

    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?


    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

  • #2
    redim preserve doesn't work for static array - see timm motl's reply in: http://www.powerbasic.com/support/pb...ead.php?t=2811

    the pb/dll help file doesn't make this clear.

    ------------------
    --dan
    Dan

    Comment

    Working...
    X