/callstack

AHK function that retrieves the current callstack.

Primary LanguageAutoHotkeyGNU General Public License v3.0GPL-3.0

callstack()

Retrieves the current callstack.

A v1 version for this exists here. I advise you to not use it if you can.

Definition

stack := callstack(limit := -1)
  • limitinteger: The amount of callstack entries to return.
    • If limit is positive or 0, stack.length equals limit.
  • stackarray of maps: The current callstack (including the call to callstack() itself).
    • Each entry represents one entry in the callstack.
    • Each entry is a map. Each map has three keys:
      • filestring: The full path of the file the entry of the callstack points to.
      • lineinteger: The line number of the line the entry of the callstack points to.
      • funcstring: The name of the function the entry of the callstack points to.

Example

test1() => test2()
test2() => test3()
test3() => callstack()

strStack := ""
for entry in test1() {
  strStack .= (
    "Line: " entry["line"] "`n"
    "File: " entry["file"] "`n"
    "Func: " entry["func"] "`n"
    "----`n"
  )
}
msgbox strStack