CALLSTK$ function

Purpose

Retrieve the details of a specific stack frame from the call stack.

Syntax

sfname$ = CALLSTK$( n )

Remarks

CALLSTK$(1) returns the name of the current Sub or Function, and the value of each of the parameters at the time it was called.  CALLSTK$(2) returns the name of the Sub or Function which called the current one, as well as its parameters.  Likewise, CALLSTK$(3) returns the one above it, and so forth.

If the CALLSTK$(n) parameter is outside the range of one (1) through the number of stack frames identified by CALLSTKCOUNT, an empty string is returned. Numeric parameters are displayed in decimal, while pointer and array parameters display a decimal representation of the offset of the target value.

Restrictions

The CALLSTK$ function can be invaluable during debugging, but it generates substantial extra code which should be avoided in a final release version of an application.  If the source code contains #TOOLS OFF, all CALLSTK$ functions which remain in the program return an empty string.

The CALLSTK$ function is "thread-aware", returning only stack frame details from the thread in which it was referenced.

See also

#TOOLS, CALLSTK, CALLSTKCOUNT, FUNCNAME$, PROFILE, TRACE

Example

FOR x& = CALLSTKCOUNT TO 1 STEP –1
  A$ = A$ + CALLSTK$(x&)
NEXT x&