Evaluate vs. Script Trigger
Let([
list1 = MBS("QuickList.New"; "Hello¶World");
list2 = MBS("QuickList.New"; "1¶2");
e = MBS("QuickList.CrossProduct"; list1; list2);
r = MBS("QuickList.GetList"; list1);
d = MBS("QuickList.Free"; list1);
d = MBS("QuickList.Free"; list2)
]; r)
This more or less is a little mini script which can execute whenever the plugin could also trigger a script. So we add new commands to evaluate with next prerelease:
CURL.SetFinishedEvaluate, CURL.SetProgressEvaluate, HotKey.SetEvaluate, Menu.SetEvaluate and MenuItem.SetEvaluate.
So instead of putting script trigger on the todo list for script triggers, you can include commands here to run them directly without waiting for the script to start. Let's try an example. We have two scripts, one to show menu and one to be triggered by menu entry:
The Show Menu script:
Set Variable [$r; Value:MBS("Trace")]
Set Variable [$r; Value:MBS("Log"; "Script start: " & Get(CurrentHostTimeStamp))]
#
# create menu
Set Variable [$menu; Value:MBS("Menu.CreateMenu")]
# create menu items...
#
Set Variable [$item; Value:MBS("MenuItem.CreateMenuItem"; "Call script")]
Set Variable [$r; Value:MBS("MenuItem.SetScriptAction"; $item; Get(FileName); "MenuScript")]
Set Variable [$r; Value:MBS("MenuItem.SetEvaluate"; $item; "MBS(\"Log\"; \"Menu Evaluate runs: \" & Get(CurrentHostTimeStamp))")]
Set Variable [$r; Value:MBS("Menu.AddItem"; $menu; $item)]
#
# Show menu
Set Variable [$m; Value:MBS("Menu.PopUp"; $Menu; "mouse")]
#
Set Variable [$r; Value:MBS("Log"; "Script ended: " & Get(CurrentHostTimeStamp))]
The MenuScript:
Set Variable [$r; Value:MBS("Log"; "Menu script starts: " & Get(CurrentHostTimeStamp))]
When we run this and show the menu, after a click the MenuScript is triggered:
The trace log:
04.03.16 16:26:45,901 FileMaker Pro[10903]: MBS Plugin called with 1 parameters.
04.03.16 16:26:45,901 FileMaker Pro[10903]: Parameter 0: "Trace"
04.03.16 16:26:45,901 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:45,901 FileMaker Pro[10903]: MBS Plugin called with 2 parameters.
04.03.16 16:26:45,901 FileMaker Pro[10903]: Parameter 0: "Log"
04.03.16 16:26:45,901 FileMaker Pro[10903]: Parameter 1: "Script start: 04.03.2016 16:26:45"
04.03.16 16:26:45,901 FileMaker Pro[10903]: Script start: 04.03.2016 16:26:45
04.03.16 16:26:45,901 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:45,902 FileMaker Pro[10903]: MBS Plugin called with 1 parameters.
04.03.16 16:26:45,902 FileMaker Pro[10903]: Parameter 0: "Menu.CreateMenu"
04.03.16 16:26:45,902 FileMaker Pro[10903]: Result: "10009"
04.03.16 16:26:45,902 FileMaker Pro[10903]: MBS Plugin called with 2 parameters.
04.03.16 16:26:45,902 FileMaker Pro[10903]: Parameter 0: "MenuItem.CreateMenuItem"
04.03.16 16:26:45,902 FileMaker Pro[10903]: Parameter 1: "Call script"
04.03.16 16:26:45,902 FileMaker Pro[10903]: Result: "11057"
04.03.16 16:26:45,902 FileMaker Pro[10903]: MBS Plugin called with 4 parameters.
04.03.16 16:26:45,902 FileMaker Pro[10903]: Parameter 0: "MenuItem.SetScriptAction"
04.03.16 16:26:45,902 FileMaker Pro[10903]: Parameter 1: "11057"
04.03.16 16:26:45,902 FileMaker Pro[10903]: Parameter 2: "Popup Menu"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 3: "MenuScript"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:45,903 FileMaker Pro[10903]: MBS Plugin called with 3 parameters.
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 0: "MenuItem.SetEvaluate"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 1: "11057"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 2: "MBS("Log"; "Menu Evaluate runs: " & Get(CurrentHostTimeStamp))"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:45,903 FileMaker Pro[10903]: MBS Plugin called with 3 parameters.
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 0: "Menu.AddItem"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 1: "10009"
04.03.16 16:26:45,903 FileMaker Pro[10903]: Parameter 2: "11057"
04.03.16 16:26:45,904 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:45,904 FileMaker Pro[10903]: MBS Plugin called with 3 parameters.
04.03.16 16:26:45,904 FileMaker Pro[10903]: Parameter 0: "Menu.PopUp"
04.03.16 16:26:45,904 FileMaker Pro[10903]: Parameter 1: "10009"
04.03.16 16:26:45,904 FileMaker Pro[10903]: Parameter 2: "mouse"
04.03.16 16:26:47,433 FileMaker Pro[10903]: Start Script "MenuScript" in file "Popup Menu" with control Pause
04.03.16 16:26:47,433 FileMaker Pro[10903]: Parameter: "11057"
04.03.16 16:26:47,433 FileMaker Pro[10903]: While running script "ShowMenu" in file "Popup Menu". User "Christian Schmitz" on host "ShowMenu"
04.03.16 16:26:47,433 FileMaker Pro[10903]: Result: 0
04.03.16 16:26:47,434 FileMaker Pro[10903]: Evaluate "MBS("Log"; "Menu Evaluate runs: " & Get(CurrentHostTimeStamp))"
04.03.16 16:26:47,434 FileMaker Pro[10903]: While running script "ShowMenu" in file "Popup Menu". User "Christian Schmitz" on host "ShowMenu"
04.03.16 16:26:47,434 FileMaker Pro[10903]: MBS Plugin called with 2 parameters.
04.03.16 16:26:47,434 FileMaker Pro[10903]: Parameter 0: "Log"
04.03.16 16:26:47,434 FileMaker Pro[10903]: Parameter 1: "Menu Evaluate runs: 04.03.2016 16:26:47"
04.03.16 16:26:47,434 FileMaker Pro[10903]: Menu Evaluate runs: 04.03.2016 16:26:47
04.03.16 16:26:47,435 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:47,435 FileMaker Pro[10903]: Result: 0 <-- Result of Evaluate
04.03.16 16:26:47,436 FileMaker Pro[10903]: Result: 1.000000 <-- Result of Menu.PopUp call
04.03.16 16:26:47,436 FileMaker Pro[10903]: MBS Plugin called with 2 parameters.
04.03.16 16:26:47,436 FileMaker Pro[10903]: Parameter 0: "Log"
04.03.16 16:26:47,436 FileMaker Pro[10903]: Parameter 1: "Script ended: 04.03.2016 16:26:47"
04.03.16 16:26:47,436 FileMaker Pro[10903]: Script ended: 04.03.2016 16:26:47
04.03.16 16:26:47,436 FileMaker Pro[10903]: Result: "OK"
04.03.16 16:26:47,436 FileMaker Pro[10903]: MBS Plugin called with 2 parameters.
04.03.16 16:26:47,436 FileMaker Pro[10903]: Parameter 0: "Log"
04.03.16 16:26:47,437 FileMaker Pro[10903]: Parameter 1: "Menu script starts: 04.03.2016 16:26:47"
04.03.16 16:26:47,437 FileMaker Pro[10903]: Menu script starts: 04.03.2016 16:26:47
04.03.16 16:26:47,437 FileMaker Pro[10903]: Result: "OK"
The output of trace shows that the evaluate is run by the menu command before the script actually ends. I separated the blocks with empty lines to make it more visible where things belong to. As you see, we call Menu.PopUp. Inside that call the script is triggered and the evaluate runs. The evaluate is now execute directly which you see on the Log call. When the evaluate is done, the Menu.PopUp call returns and normal script continues. After another log call in script, the next script is triggered to process the menu item selection.
I hope this helps if you just need to evaluate something in future and do something like writing to a log file with http://www.mbsplugins.eu/TextAppendTextFile.shtml instead of first triggering a script to do so.