cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
hogi
Level XII

Namespaces and Projects

Hi,

 

we use some Custom Functions which we share with other colleagues via an AddIn.

The "custom" namespace is created in the global namespace, functions can be accessed via custom:myfunction.

The issue: Some colleagues use Projects.
a project has it's own global namespace - and from there, custom functions are not accessible:

 

Add Custom Functions( New Custom Function( "custom", "myfunc", Function( {x}, x + 20 ) ));

project = New Project(
		Run Script(Try(custom:myfunc(1), Caption ("Namespace not accessible")));
);

 

On the other hand, it's not possible to run the script a second time inside the project [to create a duplicate custom function in the project scope]. Seems JMP finds the "global" namespace and tries to delete (!!) it:

project = New Project(
		Run Script(Add Custom Functions( New Custom Function( "custom", "myfunc", Function( {x, y}, x + y - 1 ) )));
);

hogi_0-1729494025380.png

 

How do you use/access custom functions in parallel from standard JMP and from projects?

5 REPLIES 5
hogi
Level XII

Re: Custom Functions from within Projects

Maybe a workaround:
save a symbol *) in the root namespace (via :::), to access the custom function namespace via the symbol:

::: custom = New Namespace("custom"	);

// now accessible from everywhere via  :::custom
project = New Project(
		Run Script(Caption(Char(Namespace Exists( ::: custom ))));
);


unfortunately:

Add Custom Functions( New Custom Function( "custom", "myfunc", Function( {x}, x + 20 ) ));

project = New Project(
		Run Script(Try(:::custom:myfunc(1), Caption ("content of the Namespace is not accessible")));
);

 

*) NB: Interesting - the symbol has to have the same name as the namespace (!)
. What doesn't work:

::: customNS = New Namespace(	"custom"	);

...

:::customNS:myFunc(1)

although:

is namespace(:::customNS)  // -> 1
hogi
Level XII

Re: Custom Functions from within Projects

Ah, it's not an issue with custom functions, it seems to be a  general issue with Namespaces and Projects:

::: myNS = New Namespace("myNS");

:::myNS:x ="success";

caption ("direct: "|| :::myNS:x);
wait(2);
caption(remove);

project = New Project(
		Run Script(Try(Caption("project: " || :::myNS:x), Caption ("fail")));
);

Interesting: this is how it works
... but not very practical

project = New Project(Run Script(Try(Caption("project: " || namespace(:::myNS):x), Caption ("fail"))));
hogi
Level XII

Re: Custom Functions from within Projects

I informed JMP Support (# 00170669) and got the feedback that the issues are considered to be a bug:

:::myNs; // // New Namespace("myNS", ...)
As Root(myNs); // New Namespace("myNS", ...)

//:::myNs:x; // fail in project, works in script window outside project
As Root(myNs):x // success 
Eval(:::myNs):x; // success
Namespace(:::myNs):x; // success

 

A wonderful trick: localize the root namespace:

myVar = :::myNs
myVar:x // success

many thanks, @Jasean !!! Very smooth, much more practical than namespace(:::myNS):x.

 

hogi
Level XII

Re: Custom Functions from within Projects

Previous discussion with a similar topic:

Unable to run addins within Project 

 

hogi
Level XII

Re: Custom Functions from within Projects

I just added the topic to Tiny Traps in Jmp and JSL - and bundled the Namespace related topics.