Subscribe Bookmark RSS Feed

running JSL from toolbar

MarcB

New Contributor

Joined:

Jun 23, 2017

The below code works from a script wondow, and is basically 3 different ways to change a column formula.

When I run the same code from a custom JMP toolbar it will crash on ::dt:helloworld << set formula ("5");

 

why is this? shouldn't the behavior be identical?

 

open("$SAMPLE_DATA/Amplitude 100.jmp");

dt = datatable("amplitude 100");

obj = new column("helloworld");

:helloworld << set formula("3");

dt :helloworld << set formula ("4");

::dt:helloworld << set formula ("5");

caption("Hello World");

 

3 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

There are a couple of issues.  The first is that you need to isolate your code from being impacted by other scripts, etc. that are being run.

     Names Default to Here( 1 );

does that.

Secondly, you were making incomplete references, and you were probably not seeing errors when you were running them, because their values were in the global memory space, and you had not eliminated them.

Third, in the context of your code, the statement

     

obj = new column("helloworld");

 would not have a reference, since OBJ had not been defined in your code.

The code below works on my system

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Amplitude 100.jmp" );
dt << New Column( "helloworld", character, set each value( "5" ) );
Caption( "Hello World" );
Jim
MarcB

New Contributor

Joined:

Jun 23, 2017

Are you saying global errors don't show up in the log?
txnelson

Super User

Joined:

Jun 22, 2012

If they are determined to be errors, they do show up. However, what I assume the issue is with your code not working, is that global variables that you had previously defined during your session were continuing to be found by your code, making your script not perform as you thought it should.
Jim