Page 1 of 1

Calling Stack

PostPosted: July 18th, 2015, 3:07 am
by Ajay Askoolum
The APL+Win stack (
Code: Select all
⎕si
) contains (some of)this information already but it is a little messy to extract the name of the calling function
Code: Select all
⎕si[⎕io+1]
and the {previous} line - the bit inside the square brackets.

Could you provide system variables

1. that contains the name of the calling function
2. the line in the calling function at which the jump took place
3. the line number that was being executed prior to the {current} line?

Why do I need this?

Items 1 & 2 just make like easier as they are already available in
Code: Select all
⎕si


Item 3 is needed. With
Code: Select all
⎕cse
, APL+Win has two execution contexts.
Code: Select all
⎕dm
provides information on the APL+Win execution context only. In order to report errors more precisely, the previous line number is needed. Let me demonstrate:

[1]
Code: Select all
→(0≠⎕cse 'ExecStmt' 'statement')↑Error

[2]
Code: Select all
→(0≠⎕cse 'ExecStmt' 'statement')↑Error

[3]
Code: Select all
→0

[4] Error: 'Error on line ' X (
Code: Select all
⎕cse 'GetLastError'
)

If I get to line [4], I need to know (the value of X) whether the error occurred on line [1] or on line[2]. That is, at line [4] I need to know the line from which the jump occurred. (I can work round this by simply recording
Code: Select all
⍬⍴⎕lc
on each of lines [1] and [2] - but that adds clutter!).