cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

USER defined functions: Check if the function exists/loaded after Include

dileepkr
Level III

Hi Folks,

 

I am trying to figure out a way to check if a user defined function exists before calling it. Is there a way to do this check in JMP?

 

Eg: 

user_func.jsl:

user_func = Function ({},{},

.....

);

 

Main.jsl:

Include("C:\Documents\user_func.jsl")

.

down in the code

.

.

??How to check if user_func exists??

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User


Re: USER defined functions: Check if the function exists/loaded after Include

You can use the IsEmpty() function.  See the example below;

Clear Symbols();Show( Is Empty( user_func ) );user_func = Function( {}, {} );Show( Is Empty( user_func ) );clear symbols();
Jim

View solution in original post

txnelson
Super User


Re: USER defined functions: Check if the function exists/loaded after Include

Here is how I would handle that case

func_name = "user_func";eval(parse("Show( Is Empty( " || func_name || ") ) ;"));
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User


Re: USER defined functions: Check if the function exists/loaded after Include

You can use the IsEmpty() function.  See the example below;

Clear Symbols();Show( Is Empty( user_func ) );user_func = Function( {}, {} );Show( Is Empty( user_func ) );clear symbols();
Jim
dileepkr
Level III


Re: USER defined functions: Check if the function exists/loaded after Include

That worked, thank you very much !
dileepkr
Level III


Re: USER defined functions: Check if the function exists/loaded after Include

Hi Jim @txnelson ,

 

In another case, what to do if the function name is stored as a string in a variable?

 

Clear Symbols();
user_func = Function( {}, {} );
func_name = "user_func";Show( Is Empty( Parse(func_name) ) ); //This doesnt work, any alternatives???
Clear Symbols();

 

txnelson
Super User


Re: USER defined functions: Check if the function exists/loaded after Include

Here is how I would handle that case

func_name = "user_func";eval(parse("Show( Is Empty( " || func_name || ") ) ;"));
Jim


Re: USER defined functions: Check if the function exists/loaded after Include

Names Default to Here( 1 );

user_func = Function( {}, Print( "I'm Here!" ) );
func_name = "user_func";

Show( Is Empty( Parse( func_name || "()" ) ) );