Skip to content

Instantly share code, notes, and snippets.

@hoppfrosch
Created November 27, 2013 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoppfrosch/7672038 to your computer and use it in GitHub Desktop.
Save hoppfrosch/7672038 to your computer and use it in GitHub Desktop.
Get the current AHK-callstack #ahk #script #function #debug
CallStack(deepness = 5, printLines = 1)
{
loop % deepness
{
lvl := -1 - deepness + A_Index
oEx := Exception("", lvl)
oExPrev := Exception("", lvl - 1)
FileReadLine, line, % oEx.file, % oEx.line
if(oEx.What = lvl)
continue
stack .= (stack ? "`n" : "") "File '" oEx.file "', Line " oEx.line (oExPrev.What = lvl-1 ? "" : ", in " oExPrev.What) (printLines ? ":`n" line : "") "`n"
}
return stack
}
foo1()
return
foo1()
{
foo2()
}
foo2()
{
foo3()
}
foo3()
{
foo4()
}
foo4()
{
foo5()
}
foo5()
{
foo6()
}
foo6()
{
foo7()
}
foo7()
{
throw Exception( "`n" CallStack() )
}
FileReadLine( file, line )
{
FileReadLine, data,% file,% line
return data
}
#include CallStack.ahk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment