Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check which procedure or routine called Access method
Message
From
03/05/2021 13:53:01
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
03/05/2021 13:24:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01679909
Message ID:
01680116
Views:
40
>>>>>>>>Try PROGRAM() or ASTACKINFO()
>>>>>>
>>>>>>Only SWAG: as I did not measure time needed for duplicate call in program(program(-1)-1) vs. astackinfo() filling array plus array access. I'd guess program(program(-1)-1) to be faster and to show less variation of runtime depending on stack level. When debugging or logging program state in depth: after astackinfo() you can obtain more info with ease as structure has been filled - but if you are after simple "who called me" info mentioned in yourOP to log semi automatically always hooked into your SQL operations I'd opt for function(s) call I guess to fulfill needs more KISS than others, here program(program(-1)-1).
>>>>>>
>>>>>>my 0.02 €
>>>>>>thomas
>>>>>
>>>>>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?
>>>>>Thanks.
>>>>
>>>>According to the online help PRORRAM() returns a string value, except in the case where the optional parameter is -1 where PROGRAM() will return the current program level.
>>>>
>>>>You may find occasions where a more complete "traceback" in an error log list may be useful than simply just a reference to the program in which the error was triggered (as it may provide contextual information -- i.e. "how you got here" information).
>>>
>>>First, thank you. I tested the code suggested by Thomas with a parameter -1 and I received a program name (character). I wonder why it worked for me where reading your message and reading VFP help it should have returned the program level as a number. What am I missing?
>>
>>PROGRAM() && returns the name of current program (or blank)
>>PROGRAM(-1) && returns current program level (numeric)
>>PROGRAM(-1)-1 && returns program level of caller (numeric), if entered at command line result is -1
>>PROGRAM(PROGRAM(-1)) && returns name of current program
>>PROGRAM(PROGRAM(-1)-1) && Returns name of calling program -- except at the command line where it would return 0 (numeric)
>
>Just want to point out that needing to know all this is a reason to use ASTACKINFO(). You get an array with all the information you need, and the return value of the function is the number of levels.
>
>Tamar

Hi Tamar, they where about speed issues of ASTACKINFO() vs PROGRAM(), since Dimtry likes to do this in an ACCESS_ method.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform