I'm a new user trying to learn JMP script. I've a very simple script but encountered an expected result. May be someone can give me a pointer on what did I do wrong here. Thanks in advance. (BTW: I'm using JMP 8.02)
I have a very simple table as below (test1.csv):
The following script reads in the .csv file and added two more columns to the table based on comparison of one row with its previous row. My script is below
Source_Table <<Sort(By(group_1, process_time), order(Ascending), Replace Table);
(:group_1[row()] != :group_1[row()-1]),1,
(:group_1[row()] == :group_1[row()-1]),0)));
(:tool_second[row()] != :tool_second[row()-1]),1,
(:tool_second[row()] == :tool_second[row()-1]),0
show(current data table());
/* try to output the value of the last two columns */
for (i=1, i<n_row, i++, row()=i; show(i, row(),:inspect_pt,:tool_Change););
The result table is OK but the last line of the script did not return any result on the two newly created columns. The log window showed the index becomes ::i.
But the log window showed the result of the last two columns not pulled correctly. Did I used the wrong indexing? Log window output here:
Current Data Table:DataTable("test1")
:Inspect_pt[::i]:. <-- this is not correct
:tool_Change[::i]:. <-- this is not correct
Solved! Go to Solution.
JMP doesn't finish one "command" before moving on to the next - it reads the 'new column' command and starts executing it, but continues to read and perform the next commands.
What happens here is that the 'New Column' commands are not finished executing (this type of command especially takes some time because the graphics have to be updated), before JMP reads the final line with the 'show' commands, so there are no values in the columns at the time this command is executed.
Either 'flush' the formulas as above or put a 'eval formula' directly into the 'new column' command, e.g.
new column("title", numeric, formula(:X1*:X2), eval formula);
As far as I have understood the two approaches have the same effect.
PS: I'm not from JMP
This becomes particularly important when writing scripts that use values from earlier processes for determining how to proceed (e.g. Select Where( :tool_change == 1) in order to subset). By inserting a 'run formulas' line at the end of a block of code like this, you tell JMP to pause, evaluate all pending formulas, and then proceed with the rest of the script.
I'm not as familiar with the behavior of 'eval formula' (I typically use 'run formulas' - just a matter of habit), so this is speculation, but depending on the specific processes I could see situational differences that would favor 'eval formula' over 'run formulas' (i.e. where you only care about one formula for making a decision, you could instruct only that formula to evaluate, saving the remaining formula evaluations for later). The difference here would really depend on how many formula evaluations you need to do and when you want them to be done.