CallStackDepth (System function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
Line 14: Line 14:
<li>At level-0 (immediately inside a Begin/End), <var>CallStackDepth</var> always returns <code>0</code>.  For a method or subroutine called directly from level-0 code, <var>CallStackDepth</var> returns <code>1</code>. For a method called from a method called from level-0, <var>CallStackDepth</var> returns <code>2</code>; and so on.
<li>At level-0 (immediately inside a Begin/End), <var>CallStackDepth</var> always returns <code>0</code>.  For a method or subroutine called directly from level-0 code, <var>CallStackDepth</var> returns <code>1</code>. For a method called from a method called from level-0, <var>CallStackDepth</var> returns <code>2</code>; and so on.
<li>The <var>CallStackDepth</var> method is intended to be used for problem diagnosis and, perhaps, for logging and auditing.  Using it to affect method or subroutine behavior by causing a method or subroutine to behave differently depending on the call stack depth is <b><i>extremely</i></b> poor technique, and it cannot be discouraged strongly enough.
<li>The <var>CallStackDepth</var> method is intended to be used for problem diagnosis and, perhaps, for logging and auditing.  Using it to affect method or subroutine behavior by causing a method or subroutine to behave differently depending on the call stack depth is <b><i>extremely</i></b> poor technique, and it cannot be discouraged strongly enough.
<li><var>CallStackDepth</var> is available in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.2 and later.
<li><var>CallStackDepth</var> is available in <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.2 and later.
</ul>
</ul>



Revision as of 01:32, 3 May 2011

Depth of the call stack (System class)

TheCallStackDepth shared function returns a number indicating the depth of the call stack.

Syntax

%number = %(System):CallStackDepth

Syntax terms

%numberA numeric variable to receive the current call stack depth (ie: number of nested calls).
%(System)The class name in parentheses denotes a shared method.

Usage Notes

  • At level-0 (immediately inside a Begin/End), CallStackDepth always returns 0. For a method or subroutine called directly from level-0 code, CallStackDepth returns 1. For a method called from a method called from level-0, CallStackDepth returns 2; and so on.
  • The CallStackDepth method is intended to be used for problem diagnosis and, perhaps, for logging and auditing. Using it to affect method or subroutine behavior by causing a method or subroutine to behave differently depending on the call stack depth is extremely poor technique, and it cannot be discouraged strongly enough.
  • CallStackDepth is available in Sirius Mods Version 7.2 and later.

See also

  • The actual caller associated with a particular depth can be determined using the CallStackCaller function.
  • CallStack can be used to return the same information as returned by CallStackCaller, but for every call level in the call stack.

    The number of items returned by the CallStack method will always equal the value returned by CallStackDepth at the same point in the code.