CallStack (System function)

From m204wiki
Revision as of 19:58, 1 January 2011 by 198.242.244.47 (talk) (Created page with "<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Get Call Stack<section end=dpl_desc/></b></span> CallStack function [[Category:S...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<section begin=dpl_desc/>Get Call Stack<section end=dpl_desc/>

CallStack is a member of the System class.

This shared function returns a Stringlist containing information about the current call stack: information about the caller of the current method or subroutine, the caller of that caller, and so on.

The CallStack method is available in Sirius Mods 7.2 and later.

Syntax

  %callList = %(system):CallStack

Syntax Terms

%callList
A Stringlist object to be set to reference the object that contains information about the current call stack. The first item in the Stringlist refers to the immediate caller of the current method or subroutine; a second item refers to the caller of that caller, if any; and so on.
%(system)
The class name in parentheses denotes a shared method.

Usage Notes

  • The CallStack method returns the name of the procedure and the line within the procedure that made the calls of the current method or subroutine. Generally, each returned Stringlist item has the name of the file containing the calling procedure at positions one through eight, followed by a blank, followed by the name of the calling procedure, followed by a blank, followed by the line number within the calling procedure. Note: The call stack information returned by the CallStack method refers to the (names of and line numbers in) procedures that contain the calls to the current method or subroutine, not to (names of and line numbers in) the current subroutine or method.
  • For method or subroutine calls that were entered at command level (not inside a procedure), the %callList item will contain a single asterisk character (*). If CallStack cannot determine the location of the call, the %callList item associated with a call will be null (zero-length). If not issued from within a method or subroutine, CallStack will return an empty (zero-item) Stringlist.
  • For CallStack to determine the location of a method or subroutine call, source line information must be collected at compile time. Either you must set the SIRFACT system parameter's X'01' bit, or the request must be compiled with the DEBUGUL user parameter set to a non-zero value. To use the SIRFACT system parameter, your site must be authorized for SirFact. Using the DEBUGUL user parameter increases the QTBL and (to a lesser degree) VTBL requirements for a compiled request.
  • The CallStack 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 its caller is extremely poor technique, and it cannot be discouraged strongly enough.

Example

In the MYTAX.UL procedure, the computeTax1 subroutine is called by the computeTax2 subroutine at line 146. If you issue the following statements from within computeTax1:

    %callList is object Stringlist
    %callList = %(system):CallStack
    %callList:Print

The result is something like the following:

    MYPROC  MYTAX.UL 193
    MYPROC  MYTAX.UL 146