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??
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();
Here is how I would handle that case
func_name = "user_func";eval(parse("Show( Is Empty( " || func_name || ") ) ;"));
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();
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();
Here is how I would handle that case
func_name = "user_func";eval(parse("Show( Is Empty( " || func_name || ") ) ;"));
Names Default to Here( 1 );
user_func = Function( {}, Print( "I'm Here!" ) );
func_name = "user_func";
Show( Is Empty( Parse( func_name || "()" ) ) );