- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 ) )));
);
How do you use/access custom functions in parallel from standard JMP and from projects?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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"))));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Custom Functions from within Projects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Custom Functions from within Projects
I just added the topic to Tiny Traps in Jmp and JSL - and bundled the Namespace related topics.