Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

stack macro callstk

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

  • stack macro callstk

    This might save a few lines of typing when you want to check that the call stack is not currupted. And it probably isn't corrupted, by the way.

    Code:
    '
    ' just a little macro to wrap callstk, etc
    ' PB 8 or 9 - example is PB9
    ' Chris Holbrook Feb 2009
    '
    #tools on
    #compile exe
    #dim all
    '------------------------------------------------------
    ' <<<<< THIS IS THE MACRO - the rest of the code just gives it something to do.
    macro mShowStack(debugmsg)
        macrotemp s, i
        dim s as string
        dim i as long
    
        s = funcname$ + " : " + debugmsg + $crlf
        for i = 1 to callstkcount
           s = s + $crlf + callstk$(i)
       next
       ? s
    end macro
    '>>>>> END OF THE MACRO
    '------------------------------------------------------
    class myClass
         interface MyInterface
             inherit iunknown
             method StackTestMethod (n as long )
                 mShowStack("shouldbefirst")  '<================== macro used here
             end method
         end interface
    end class
    '------------------------------------------------------
    sub StackTestFn ( n as long)
        mShowStack("shouldbesecond") '<================== macro used here
    end sub
    '------------------------------------------------------
    callback function CBHD
        local myi as myinterface
        select case as long cb.msg
    
            case %wm_command
                if cb.ctl = 100 then
                    if cb.ctlmsg = %bn_clicked then
                        myi = class "myClass"
                        myi.StackTestMethod(1)
                        StackTestFn(2)
                    end if
                end if
        end select
    
    end function
    '------------------------------------------------------
    function pbmain () as long
        local s as string
        local hD as dword
    
        dialog new pixels, 0, "Show Call Stack Info", 200, 200, 200, 100, %ws_sysmenu or %ws_caption, to hD
        control add button, hD, 100, "Call Stack Info", 25, 25, 150, 20
        dialog show modal hD call CBHD
    end function
Working...
X