run table scriptWhat is the difference between running a Table Script via the green Play icon:

... and via the Run button?

Automation and ScriptingRe: run table scriptIs there are reason to suspect that there is a difference? From the script "window" you can for example run separate parts by highlighting them.
Re: run table scriptThey generally do the same thing.
The little green arrow is faster, one click.
: )
Re: run table scriptAfter inventing the 3rd "solutions" to a "timing issue" in a table script - unfortunately without real success
... I found out that the actual difference was:
- run the script via the play icon → issue
- open the script window - [try some new code ... or nothing] - and click on the Run button → no issue.
Re: run table scriptRunning by clicking on the Green Run Arrow, runs the script on the data table it is attached to.
Running the script from the Edit window, runs the script on the Currently Active Data Table, which may not be the data table the script was saved to.
Re: run table scriptI thought so too ...
Re: run table scriptGood idea,
but actually, for "Edit" mode I paid attention to have "my table" active before clicking on run.
And: it is the "Edit" mode which works 
:)maybe it's related to a current data table() somewhere in the code - which might act differently if the script is started via the play icon - or via the Run button.
:)just putting a :)current data table() directly into a table script did not show a difference between the two approaches.
But my code is a lengthy chain of JSL, Main Menu (" ... "), open file, join, concatenate ...
:)I will try to reduce the complexity to show the difference - or to generate an anonymized example ...
Re: run table scriptI tried adding
current data table();
to see if it would point the script back to the data table the script was saved on, and it did not. The script ran against whatever data table the current data table was.
Re: run table scriptCurrent Data Table() cannot be relied on in either of those cases. If new table opens immediately after you press green triangle, the current table can change before script is executed (most likely not that likely to happen with green run button but it could). Fairly easy to test with script like this
wait(1);
Caption(Current Data Table() << get name);
Run the script by pressing green triangle and immediately press Ctrl+N to create new table.
It does seem though that if you leave Current Data Table() out it will trigger on the table which script was run from (in both cases)
wait(1);
Current Data Table() << New Column("A");
vs
wait(1);
New Column("A");
Re: run table scriptConcerning my issue
Actually, at the end, it was a timing issue
...like Jarmo described it - but kind of inverse:
I use a customized AddIn to load a file.
And as Main Menu cannot return a return value
,
I used current data table() to get access to the newly created table
this was the idea ...
//<FONT face="courier new,courier">Open( "$SAMPLE_DATA/Big Class.jmp" );</FONT><BR />Main Menu("load_");
// wait(1);
dt= current data table(); // the idea: myDT
caption(dt << get name())
a) If I just use Open( "$SAMPLE_DATA/Big Class.jmp" ), everything is smooth.
On the other hand, after opening the data table via Main Menu("load_") ,
current data table still referred to my main table (!).
Activating the wait(1) solved the issue - with 1 second penalty fee.
b) To make it more robust (and faster), I created a table reference :::load_:myTable inside FUNC and used dt=:::load_:myTable instead of the original approach via current data table().
Interesting:
The approach via :::load_:myTable works without the wait(1).
This means that I can already communicate with the new table before it gets the current data table()!
so, maybe worth to investigate, how fast data tables get the current data table()
... and why there are differences.
Re: run table scriptComing back to the start of the discussion - the difference between the green play icon and the "run" button of the edit window:
@Byron_JMP wrote:
They generally do the same thing.
The little green arrow is faster, one click.
: )
the issue boils down to the finding that there is not ONE well define current data table()!
Using the green play button and checking the result windows, one can see the following sequence:
1) the AddIn opens test and reports that current data table was changed to test
2) the main table still thinks that check_current_data_table is the current data table (!!!)
3) After the wait(0) it knows better and returns test.
On the other hand - if the script is started via the RUN button in the edit window - all 3 result windows show the same table as current data table().
main script:
Names Default To Here( 1 );
Main Menu( "load_" );
win = new window("1 ",Text Box ("main table (1):\!n" ||
(current data table() << get name())));
wait(1);
win = new window("2 ",Text Box ("main table (2):\!n" ||
(current data table() << get name())));load_:
Names Default To Here( 1 );
dt = open("C:\temp\test.csv");
Caption( {100, 200}, "postprocessing ...");
win = new window("addIn", text box("inside the addin:\!n" ||(current data table()<< get name())));
// win << moveWindow( 100, 100 );
Caption( remove );
Digging deeper, one finds out that tiny details like enabling the << moveWindow inside the AddIn or disabling one of the caption commands have an effect on the behavior.
Re: run table scriptBy the way the same issue:
there is not ONE well define current data table()!
was also the issue which triggered this post: ThisDataTable() ?
with the same bugfix:
add wait ( 0 )
in front of
dt = current data table()!