在Foxpro中如何获取用于记录的调用堆栈信息

时间:2010-09-02 20:09:55

标签: stack call foxpro

在Foxpro中如何获取用于记录的调用堆栈信息。(不使用调试器ui,但在运行时使用代码)

2 个答案:

答案 0 :(得分:4)

您可以使用ASTACKINFO()函数创建一个填充了调用堆栈的数组。

答案 1 :(得分:1)

像MikeReigler那样使用ASTACKINFO,然后就是这样:

    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