cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

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

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

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 || "()" ) ) ); 

Recommended Articles