Namespace

Posted: 2017-01-20 in Namespaces

Namespaces allow you to declare public variables, which are only public within that namespace. So, I could have 2 separate public variables called m_var, providing at least one of them was in a namespace. A procedure or function with the same namespace declared would be able to access the m_var from that namespace or it could be accessed as namespace.m_var from anywhere. It’s useful if there is a risk of having conflicting public variable names – for example, if you are adding Page or Section templates or Pages from the Page Library to your App.


by specifying the namespace in a delegate or procedure, variables do not need to be prefixed by the namespace.

Code:
proc myDelegate()
    namespace PeopleKiosk 
    Public myvar
    // peoplekiosk.myvar and myvar reference the same variable
endproc

Tip #1: you can use the namespace() function to save the current namespace and set it back later in your code.
Tip #2: To disable the namespace just specify

Code:
namespace none
// or
namespace

Tip #3: how to inspect a namespace? Try this in the console.

Code:
namespace barry
public myvar = "hello world"
? barry

Surprise surprise, namespaces are just objects that encapsulate public variables and other things (more on that later).


Q:
I have a desktop app and I wish to make variable initialised in one page visible to all other pages
In my case, my initial page is a page with custom section
I have public some variables and initialised the values of these public variables but I am not able to see the variables value in other pages
May I know how I can expose the variables created in my custom section of my initial page to all other pages
A:
You probably have a namespace statement in your custom section code. That being the case you need to prefix the reference of your public variables by the name of the namespace e.g.

namespace myns
Public ui_message

in another page you must reference it like this
myns.ui_message



 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s