cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
shuey
Level I

How to use Name Expr of functions inside dt << New Script

I have a JSL script that has the following:
There is a function stored in a variable toJournal:

toJournal = Function({},
     //some commands
);

I want to call this function inside a New Script message:

dt << New Script("save presentation",
toJournal();
journal << save presentation();
);

however due to name scope where I use names default to here(1) in my main script, the function toJournal isn't known when running the save presentation script button in the Data Table.

I would like to use Name Expr or some other command to have the function contents (in text) be inserted into the new script for evaluation when pressing the data table script button.
I've tried many options with no luck, for instance wrapping the function definition in Expr(), and using Expr, Name Expr...

dt << New Script( "Save Presentation All", 
		Eval Expr(Name Expr(toJournal));
		jj << save presentation();
);


Any Help would be very much appreciated

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to use Name Expr of functions inside dt << New Script

Try it this way.

 

Names Default To Here( 1 );
dt = Data Table( "Big Class" );
toJournal = Function( {},
	Print( "Hello, world!" )
);
Eval( Eval Expr( dt << New Script( "Guess What", Expr( Name Expr( toJournal() ) ) ) ) );

 

mmarchandFSLR_0-1760529981442.png

 

View solution in original post

1 REPLY 1

Re: How to use Name Expr of functions inside dt << New Script

Try it this way.

 

Names Default To Here( 1 );
dt = Data Table( "Big Class" );
toJournal = Function( {},
	Print( "Hello, world!" )
);
Eval( Eval Expr( dt << New Script( "Guess What", Expr( Name Expr( toJournal() ) ) ) ) );

 

mmarchandFSLR_0-1760529981442.png

 

Recommended Articles