Results 1 to 4 of 4

Thread: How do I declare a variable to be used by all sections in a page?

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    348

    How do I declare a variable to be used by all sections in a page?

    Hi all

    I need to be able to declare a variable that is visible to all sections within a page

    Your advice is much appreciated

    Thanks & Best Regards

  2. #2
    Lianja Support Team lianjasupport's Avatar
    Join Date
    Feb 2012
    Location
    Boston USA, Wokingham UK
    Posts
    1,268
    Just put it in your namespace in the page init delegate.

    e.g.

    namespace PeopleKiosk
    public MyVar = 0

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,099
    ...and reference it in every section as:

    PeopleKiosk.MyVar = expression





    Last edited by barrymavin; 2015-01-07 at 10:08. Reason: Changed "call" to "reference"

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,695
    Also note that by specifying the namespace in a delegate or procedure, variables do not need to be prefixed by the namespace.

    e.g.

    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).
    Last edited by barrymavin; 2015-01-07 at 10:33.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us