ASTACKINFO( ) Function

Creates an array and populates it with information about the current state of the call stack.

AStackInfo(ArrayName)

Parameters

  • ArrayName
    Specifies the name of the array that will contain the information about the examined object. The following table describes the information returned by the ASTACKINFO( ) function:
    Array Element Description
    1 Call Stack Level
    2 Current program filename
    3 Module or Object name
    4 Module or Object Source filename
    5 Line number in the object source file
    6 Source line contents

Return Value

Numeric

Remarks

ASTACKINFO( ) populates an array with information about the entire calling stack. It combines functionality of SYS(16) and Program( ) while adding new support for line numbers at each call stack level. The value returned is the number of program levels or rows of the returned array.

ASTACKINFO( ) only populates the 6th array element if source line contents are available, otherwise it will be left empty.

ASTACKINFO( ) provides, in the 2nd and 4th elements respectively, the name of the current file and, if the file is bound in an APP or other separate file, a full path name to the binding program.

The 4th element contains the original source file information. For objects, this is same information returned by SYS(16), even when bound inside of applications.

Note   For PRG files it may be difficult to gather this information. In that case we simply display the 2nd element similar to what SYS(16) does today.

Example

A modeless form bound in an APP file (myAppl.app) with a button from buttons.vcx class (also in the APP). The developer runs myAppl.app in Visual FoxPro to display the form (the form remains open because this is not run time Visual FoxPro). When the user clicks the button to run the report, the report (which exists outside of myAppl.app) calls a query form in its BeforeOpenTables event.

This query form (getcusts.scx), which resides inside of myAppl.app, issues a call to ASTACKINFO( ) [then displays the resulting array as in the following example].

ASTACKINFO(myarray)
DISPLAY MEMO LIKE myarray
myArray
(1,1)   1                                    && Stack level = 1
(1,2)   c:\vfp\myAppl.app                        && Current program
(1,3) frmRerport.PrintReport.Click         && Object
(1,4) c:\vfp\myclasses\buttons.vct         && Object source file name
(1,5) 42                              && Line number in the source 
(1,6) THISFORM.DoReport()                  && in the source 
(2,1)   2                                    && Stack level = 2
(2,2) c:\vfp\myAppl.app
(2,3) frmRerport.DoReport
(2,4) c:\vfp\forms\frmRerport.sct         && Module source file name
(2,5) 31
(2,6) DO RunListReport                     && in the source 
(3,1)   3                                    && Stack level = 3
(3,2) c:\vfp\myAppl.app
(3,3) 
(3,4) c:\vfp\programs\runlisterport.prg   && Module source file name
(3,5) 12
(3,6) REPORT FORM myreport1.frx            && in the source 
(4,1)   4                                    && Stack level = 4
(4,2) c:\vfp\reports\myreport1.frt
(4,3) myreport1.DataEnvironment.BeforeOpenTables
(4,4) c:\vfp\reports\myreport1.frt          && Module source file name
(4,5) 31
(4,6) DO FORM getcusts                     && in the source 
(5,1)   5                                    && Stack level = 5
(5,2) c:\vfp\myAppl.app
(5,3) getcusts.init
(5,4) c:\vfp\forms\getcusts.sct            && Module source file name
(5,5) 2
(5,6) ASTACKINFO(myarray)                  && in the source 

See Also

Arrays | Objects | Call Stack Window | LINENO( ) | PROGRAM( )