tags:

views:

42

answers:

2

In Foxpro how to get Call stack info for logging.(not using the debugger ui, but in code at runtime)

+3  A: 

You can use the ASTACKINFO() function to create an array filled with the call stack.

MikeReigler
+1  A: 

use ASTACKINFO like MikeReigler said, then something like this:

    cStack = ""
    nStackCount = astackinfo(arrStackInfo)

    for nCount = nStackCount to 1 step -1

        cStack = cStack + "Level " + transform(arrStackInfo(nCount, 1)) + chr(13)
        cStack = cStack + iif(not empty(arrStackInfo(nCount, 2)), ;
            "Filename: " + transform(arrStackInfo(nCount, 2)) + chr(13) , "")
        cStack = cStack + iif(not empty(arrStackInfo(nCount, 3)), ;
            "Module/Object name: " + transform(arrStackInfo(nCount, 3)) + chr(13) , "")
        cStack = cStack + iif(not empty(arrStackInfo(nCount, 4)), ;
            "Module/Object filename: " + transform(arrStackInfo(nCount, 4)) + chr(13), "")
        cStack = cStack + iif(not empty(arrStackInfo(nCount, 5)), ;
            "Line # : " + transform(arrStackInfo(nCount, 5), "999999") + chr(13), "")
        cStack = cStack + iif(not empty(arrStackInfo(nCount, 6)), ;
            "Code: " + transform(arrStackInfo(nCount, 6)) + chr(13), "")
        cStack = cStack + chr(13)

    next
Stuart Dunkeld