CALLSTKCOUNT function

Purpose

Retrieve the number of stack frames in the call stack.  Used in conjunction with the CALLSTK$ function.

Syntax

count& = CALLSTKCOUNT

Remarks

CALLSTKCOUNT returns a Long-integer value that represents the total number of stack frames that currently exist on the application call stack.

Retrieve individual stack frame details with the CALLSTK$ function, or write them all to a disk file with the CALLSTK statement.

Restrictions

The CALLSTKCOUNT function, when used in conjunction with the CALLSTK$ function, can be invaluable during debugging, but its use generates substantial extra code which should be avoided in a final release version of an application.  If the source code contains #TOOLS OFF, all CALLSTKCOUNT functions which remain in the program return zero.

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

See also

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

Example

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