Subscribe Bookmark RSS Feed

Script Execution Problem

v_r

Community Trekker

Joined:

Nov 20, 2014

Hi,


Has anyone else experienced this issue where part of a script will not execute properly when the entire script is run, but will execute properly when run line by line. I've experienced this a few times with JMP 7 and 11. I just wanted to clarify if it's a syntax error, or perhaps settings or code logic on my behalf and not just a bug in JMP?

The most recent time I noticed it was with setting column formulas. I'm concatenating characters and then making the new column numeric to be used in other calculations. Col A and B are characters without any alphabets in them. When I run it line by line it executes like it should, however running the entire script results in a blank column.

Thoughts?

  

dt1 << add multiple columns( "Col C" after( "Col B"), character, nominal );




Column( "Col C)<<Formula( Concat(:Name( "Col A" ),:Name( "Col B" ) ));



Column( "Col C" )<< delete formula;



Column( "Col C" )<< Data Type( Numeric ) << Modeling Type( Continuous );







I've also noticed this issue with scripts that select and filter rows based on specific conditional statements.

4 REPLIES
David_Burnham

Super User

Joined:

Jul 13, 2011

A column formula is calculated asynchronously, so your script will continue even if the formula hasn't completed evaluation.  To ensure that your script continues only upon completion of formula evaluation you can send the Run Formulas message to the data table:

Column( "Col C)<<Formula( Concat(:Name( "Col A" ),:Name( "Col B" ) ));

dt << Run Formulas;

-Dave
v_r

Community Trekker

Joined:

Nov 20, 2014

Thanks for the quick replies guys!

Unfortunately I do have those lines in there as well. I may have accidentely deleted them while mocking up the pseudo code.

Here's a better excerpt of code:


dt1 << add multiple columns( "Bioburden", 1, after( "Bioburden B"), character, nominal );


Column( "Bioburden")<<Formula( Concat(:Name( "Bioburden A" ),:Name( "Bioburden B" ) ));


dt1 << Run Formulas;


Column( "Bioburden ")<< delete formula;


wait(1);


Column( "Bioburden  )<< Data Type( Numeric ) << Modeling Type( Continuous );


dt1 << delete column( :Name( "Bioburden A" ) );


dt1 << delete column( :Name( "Bioburden B" ) );


I don't have the second run formulas() after I delete my formula in the fourth line. I've never used it like that before.


Byron_JMP

Staff

Joined:

Apr 26, 2012

when you replaced the Wait () with a Run Formulas, did the script run?

I could reproduce the glitch you were finding, maybe this slightly different approach would work for you?

In this case I didn't use "add multiple columns", and then moved the column to the front of the line at the end.

names default to here(1);

dt =New Table();

dt << New Column( "A", Character, Nominal, Set Values( {"1", "2", "3"} ) );

dt << New Column( "B", Character, Nominal, Set Values( {"4", "5", "6"} ) );

dt << New Column( "C", character, Nominal, formula( :A || :B ) );

:C << delete formula();

:C << data type( numeric ) << set Modeling Type( Continuous );

dt << Go To( C );

dt << Move Selected Columns( "to first" );

Byron_JMP

Staff

Joined:

Apr 26, 2012

The issue is that column formula isn't evaluated completely before the next step happens.

dt<<run formulas(); makes sure the formulas are evaluated before letting the next step happen. In my hands this works a lot better than using wait(1);

dt1=current data table();

dt1 << add multiple columns( "C",1, after(:B ), character  );

Column( "C")<<Formula( Concat(:Name( "A" ),:Name( "B" ) ));

dt1<<run formulas();

Column( "C" )<< delete formula;

dt1<<run formulas();

Column( "C" )<< Data Type( Numeric ) << Modeling Type( Continuous );