A Little Common Sense Never Hurts

When defining and using variables, be sure to think about when and where they will be used, and what their values will be at that point in time. A variable that is only assigned a value at the end of the installation process won't have a value at the start.

For example, let's say you set up a User Information screen that asks the user for their name and stores it in a variable called %UserName%. It's important to realize that %UserName% won't contain the user's name until after that screen is shown. If the User Information screen is only displayed at the end of the installation process, %UserName% won't have a value at the beginning when your Welcome screen is shown. In this case, including %UserName% in the text of your Welcome screen would result in a message like "Hello %UserName%" instead of a message like "Hello Mary Lou."

The same is true for variables that you define on action tabs. When you assign a value to a variable using an action, the value doesn't get assigned to the variable until the moment the action is performed. A variable that you define on an action tab is only available to the actions that are listed below it on the tab, and to the actions on tabs that are performed "later" in the installation process. If you try to use the variable in another action higher "up" on the action tab, or on an action tab that happens earlier in the installation process, the variable won't have a value yet, and your installer probably won't work properly.

In other words, when you define a variable with an action, it is only available to the parts of the installation that are performed after that action. If you want to use a variable in a screen condition to control whether that screen is shown, make sure a value is assigned to the variable before it's that screen's turn to be displayed. If you want to use a variable in a run-time install condition, make sure a value is assigned to the variable before all the files are installed.

 

See Also: Variables, Defining Variables with Actions, Defining Variables with Screens, What Can You Do With Variables?