cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
nthai
Level III

How to access Here namespace during entered Local Here namespace?

Hi all,

I'm having trouble to access the Here namespace during entered Local Here namespace. My example script as follow:

 

Names Default To Here(1);
Delete Symbols();
// Declare a variable in the "Here" scope
x = "Variable";
Local Here(
    // Access the "Here" scope variable
    y = Eval(Namespace("here") << Get("x"));
    Show(y);
);

When I used debugger, can clearly see after entered Local Here, it has 2 Here scopes. My guess is one from Here, and the other from Local Here. I have tried several approaches, but none works so far.

5 REPLIES 5
jthi
Super User

Re: How to access Here namespace during entered Local Here namespace?

I think you can't directly (that is kinda the purpose of Local Here)

 

jthi_1-1727855324539.png

Programming Functions (jmp.com)

 

-Jarmo
nthai
Level III

Re: How to access Here namespace during entered Local Here namespace?

Hi jthi,

 

If that the case, could you advise what is the best approach for "root namespace"? I'm using Global namespace right now and intent to leverage to Here namespace and avoid namespace pollute. My script is involved ~80 variables.

jthi
Super User

Re: How to access Here namespace during entered Local Here namespace?

Depends on what you are doing. You can utilize named namespaces, anonymous namespaces, global, here, local,... but still, I would almost always start my scripts with Names Default To Here(1);

-Jarmo
hogi
Level XII

Re: How to access Here namespace during entered Local Here namespace?

Without the Names Default to HERE(1)  the generated variables will "pollute" the Global Namespace.

With the Names Default to HERE(1)  the generated variables will "pollute" the Here Namespace.

 

To organize the variables, you can create your own namespace and create the variables there:

 

Names Default To Here(1);
Delete Symbols();
// Declare a variable in the "Here" scope
x = "Variable";

//get the value
ns = Namespace("here");
val = ns << Get Value("x");
Print(val);
Show(x);


new namespace("myNS");
NS:x = "variable";
Show(NS:x)
hogi
Level XII

Re: How to access Here namespace during entered Local Here namespace?

It's strange that there are two HERE namespaces and that they show the same content - the one of the local here.
When you step out of the local here, there is just a single Here namespace and it correctly hows the content of the Names Default to Here(1) one.

Another issue with JSL debugger:
since JMP15 the local namespace of functions is not accessible anymore: Function locals in JSL Debugger