Announcement

Collapse
No announcement yet.

How do Session Variables work?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do Session Variables work?

    Question
    How do Session Variables work?

    Answer
    Session Variables Explained

    Session variables are used in Setup Factory 7.0 to hold various forms of data that can then be displayed to the user through screens, and/or used in script. For example, %AppFolder% is a Session Variable that has many uses in Setup Factory.

    When the data contained in a Session variable must be displayed to the user through a screen, the session variable can be referenced 'as is'. For example:
    Code:
    %AppFolder%\\myfile.txt
    However, to use a Session variable within LUA script, the data from the Session variable must first be expanded. Setup Factory 7.0 ships with a built-in action to accomplish this task: SessionVar.Expand().

    For example:
    Code:
    File.Open(%AppFolder%\\file.txt, "", SW_SHOWNORMAL);
    The above script would fail, even if file.txt existed in the location referenced in the Session variable %AppFolder%. This is because the data from the variable was not expanded. The proper script is as follows:

    Code:
    -- This action saves the value of a Session variable into a Lua variable.
    AppFolder_Lua = SessionVar.Expand("%AppFolder%");
    -- You can then use this Lua variable to reference the file.
    File.Open(AppFolder_Lua.."\\file.txt", "", SW_SHOWNORMAL);
    Or alternatively, the SessionVar.Expand() action can be used:
    Code:
    File.Open(SessionVar.Expand("%AppFolder%").."\\file.txt","",SW_SHOWNORMAL);
    When data must be stored in a Session variable, the built-in action SessionVar.Set must be used:

    Code:
    SessionVar.Set("%NewVariable%", "I am a value!!");
    For more information please see the following topics in the Setup Factory help file:

    Program Reference | Variables | Session Variables
    Last edited by Adam; 04-29-2008, 12:12 PM.
Working...
X