Results 1 to 3 of 3

Thread: [Answers] Variable

Threaded View

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] Variable

    Q:
    Is there are way to declare a global variable that is only available to the current prg file and not to other prg files?
    A:
    If it is public, it will be accessible throughout the App and from the Console, so you should be able to check its value or do a LIST or DISPLAY MEMORY to see it.
    Is the file where you added the public declaration a custom library or a separate prg that you have created?
    You could declare the variable under different namespaces for different pages, but that would mean accessing it as namespace.variable, so probably simpler to have different variables if they have different uses.



    Q:
    I need to be able to declare a variable that is visible to all sections within a page
    A:
    Just put it in your namespace in the page init delegate.
    e.g.
    Code:
    namespace PeopleKiosk 
    public MyVar = 0


    Q:
    How do I delete this object that is created?

    Code:
    myform = createobject("form")
    A:
    Code:
    release myform
    or
    Code:
    myform = .f.
    If the form is displayed you need to close() it or release() it.



    variables have to be declared beforehand. This prevents potential spelling errors of variables in your assignments.
    Yes you can use m.var notation, and yes it it slightly faster as fields in the active cursor do not need to be looked up. Lianja uses a hashed block-structured symbol table so lookups are quite fast anyway. It does not do a sequential search.



    Code:
    Lianja.localstorage.setItem( key, value )
    and
    Code:
    Lianja.sessionstorage.setItem( key, value )
    And the corresponding getItem() on these work between desktop and web//mobile



    In v1.2 (should be released today) you also have this that you can use in the Desktop and Web Client to maintain state between Apps.
    Code:
    Lianja.localStorage.setItem(key, value)
    and
    Code:
    value = Lianja.localStorage.getItem(key)
    Also...
    Code:
    Lianja.sessionStorage.setItem(key, value)
    and
    Code:
    value = Lianja.sessionStorage.getItem(key)
    In a point release I will "persist" the localStorage in the desktop client so that it is there next time an app runs.
    You can store e JSON encoded object and use json_decode(value) to restore the state of an object.



    Q:
    Is there a comparable way to define a 2-column array?
    A:



    Alternatively if you know JSON you can create objects and arrays with members that are objects and arrays like this:






    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-02-08 at 02:18.

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