System Functions
STK( ) Program Call Stack
   
Format
1: Retrieve CALL stack information: STK(level[,ERR=stmtref])
2: Retrieve list of arguments: STK( PROPERTIES )

Where:

level Program CALL stack level. Numeric expression.
string$ String expression to be processed.
   
Returns String, program line number (characters 1 to 5) plus full pathname.
   
Format 1 Format 1 of the STK( ) function returns a character string reporting the program line number (5 digits) and program (full pathname) being executed at the program level specified. Use a negative value to specify a level that is relative to the current level. ProvideX returns an Error #41: Invalid integer encountered (range error or non-integer), if your given level does not exist.
   
Example The current directory is "/usr/test". In program "PROG1":
 
0100 CALL "STACKER"
 
In program "/usr/test/STACKER"
 
0010 PRINT "Level 1=",STK(1)
0020 PRINT "Level 2=",STK(2)
0030 PRINT "Level -1=",STK(-1)
 
When run:
 
Level 1=00100/usr/test/PROG1
Level 2=00020/usr/test/STACKER Level -1=00100/usr/test/PROG1
 
The next example prints all the programs in the stack:
 
0010 I=1-PRM('B0')
PRINT STK(I,ERR=*NEXT); I=I+1; GOTO 20


*Note* You can use PRM('B0') to circumvent a potential problem should the base level be level 0, rather than 1.


Format 2 The STK( PROPERTIES ) function returns a character string which identifies the type and number of arguments passed into the current program. Each character of the string represents the type of calling argument. The possible character values are:
Character Description
S The argument is a string variable and changes in the subprogram will be returned to the variable passed by the caller.
s The argument is a string expression and changes in the subprogram will not be returned to the caller.
N The argument is a numeric/integer variable and changes in the subprogram will be returned to the variable passed by the caller.
n The argument is a numeric expression and changes in the subprogram will not be returned to the caller.
R The argument is a composite string with a format and changes in the subprogram will be returned in the variable and its associated components in the caller.
A The argument is a string array and changes in the subprogram will be reflected in the array passed by the caller.
a The argument is a numeric/integer array and changes in the subprogram will be reflected in the array passed by the caller.
   
Example The following table provides some examples of the values return for various combinations of CALLs:
Call Arg list STK( PROPERTIES) Value
X,Y$ "NS"
X,X+1 "Nn"
INT(N), UCS(X$),Y$ "nsS"
X${ALL},N,(Y$) "ANs"