Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check which procedure or routine called Access method
Message
From
04/05/2021 03:40:22
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01679909
Message ID:
01680120
Views:
55
>A follow-up question please. So far, my test shows that program(program(-1)-1) will give what I am looking for.
>Since I write this value to a log file, I want to be sure that it is always a string, not a numeric value. Can you think of a case where program(program(-1)-1) will give a numeric value?

Saw that you already got great responses ;-)
Danger only rises when the levels subtracted are greater than actual stack depth, as *any* negative number as parameter will return numeric.
In practice you are probably safe to chain 2 or even 3 previous levels into single log line unless you are in actual start code.
Trying for more levels default approach should go to astackinfo with a guard, unless specific reason speaks against it.
Of course you could always guard with
program(max(0, program(-1)-wantedlevell)
calls against weird situations, but JR hints at other solution perhaps easier to grok in 6 months.
In this case speed freak in me does neither ;-)

regards
thomas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform