MAXScript Debugger >

# Manual Stack Dump using the Stack() Function

Syntax:

    stack threadID:<int> showLocals:<bool> firstFrameOnly:<bool> to:<stream>

This function dumps the call stack, showing the nesting of function calls at the current execution point.

If threadID: is not specified, the current thread is dumped. If a thread ID is supplied, the specified thread is dumped. See the threads() method further on this page.

If showLocals: is not specified or supplied as true, the local variables in each stack frame are dumped.

If firstFrameOnly: is not specified or supplied as false, all stack frames are displayed. If supplied as true, only the current stack frame is displayed.

If to: is not specified, output is sent to the MAXScript Listener, otherwise to the supplied stream.

FOR EXAMPLE:
    fn test somevalue = (ss=stringstream"";stack to:ss;ss)
    fn test2 = (xx = pi; test xx)
OUTPUT:
    test()
    test2()
    StringStream:"** thread data: threadID:1184
    ** ------------------------------------------------------
    ** [stack level: 0]
    ** In test(); filename: ; position: 52; line: 1
    --  Parameters:
    --   somevalue: 3.14159
    --  Locals:
    --   somevalue: 3.14159
    --   ss: StringStream:""
    --  Externals:
    --   owner: undefined
    ** ------------------------------------------------------
    ** [stack level: 1]
    ** called from test2(); filename: ; position: 88; line: 2
    --  Locals:
    --   xx: 3.14159
    --  Externals:
    --   owner: undefined
    --   test: Global:test : test()
    ** ------------------------------------------------------
    ** [stack level: 2]
    ** called from top-level
    "