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:
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:
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:
Or alternatively, the SessionVar.Expand() action can be used:
When data must be stored in a Session variable, the built-in action SessionVar.Set must be used:
For more information please see the following topics in the Setup Factory help file:
Program Reference | Variables | Session Variables
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
For example:
Code:
File.Open(%AppFolder%\\file.txt, "", SW_SHOWNORMAL);
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);
Code:
File.Open(SessionVar.Expand("%AppFolder%").."\\file.txt","",SW_SHOWNORMAL);
Code:
SessionVar.Set("%NewVariable%", "I am a value!!");
Program Reference | Variables | Session Variables