I don't think you can with just FileMaker scripting and calculations. (Never know what might be possible with a plug in.)
To get the name of the button that was pressed, pass it as a script parameter to the script.
You could probably load a global variable with your own stack of script calls. The first step of each script could be a step that pushes the name of that script onto the stack. The last line of the script can pop it off the stack.
Thank you Phil. I already used this technique with the global variable, but it is very awful, especially when you create scripts with several entry points (as it is in my case).
About button name, I would like to use the “Pause/Resume Script” instruction for a data entry window.
The problem is that if I define a button with the command “Resume Script”, I do not know the name of the button (in the layout I want to have two buttons: the first to accept the data and the second to cancel the operation, but without cancelling the script). I did not find any other way to resume a script and getting different states of the resume.
This would simplify my life, but I already solve the problem using a multi entry point script.
How would you write a script in FileMaker with "several entry points"? Each script has exactly one entry point, the first line of the script. Do you mean you have a script that uses Perform script in several points in it to call other scripts? I don't see that as a major issue for this method as you put your "push" script step (a set variable that uses List to push new text onto the begining of a list of values) in the first line of the script that is called, not the script that has the multiple perform script steps.
You would not be able to use a single step button and also capture its name, but you can always write a scripted button that does the same thing as the single step button and which can then capture the button name from the parameter passed to it.
Write a script that actually does nothing but update the stack by pushing the button name on to it.
Set Variable [$$CallStack ; List ( Get ( ScriptParameter ) ; $$CallStack )]
select the "resume" option in button setup at the same time you specify perform script to perform the above script. Clicking the button will then resume the paused script, but also logs the name of the button clicked.
Thank you. I forgot that I can resume a paused script calling another one.
I know that each script has one entry point. At the beginning, I use a set of "if" and "elseif" that test the parameter to simulate different entry points.
I don't see how that complicates pushing the name of the script onto a call stack variable. Just put that code before the first IF.