Variables

Global variables are variables whose values are automatically set when your patch starts. They are used in action script to represent common values that might differ between systems. These variables are all global which means you can use them anywhere in your project.

Tip: The built-in global variables are listed along with all of the actions and constants when you press Ctrl+Space in the action editor. Since all of the built-in variables start with an underscore, if you type _ and then press Ctrl+Space, you'll be taken right to the first built-in global variable in the list.

The following global variables are available in Visual Patch:

_CommandLineArgs

A numerically indexed table that contains the command line arguments passed into the patch executable.

_DesktopFolder

The path to the user's Desktop folder. On Windows NT/2000/XP/Vista or later, this is the path from the per-user profile.

_DesktopFolderCommon

The path to the user's Desktop folder. On Windows NT/2000/XP/Vista or later, this is the path from the All Users profile. On a non-Windows NT system, this will simply be the path to the user's Desktop folder (the same as _DesktopFolder).

_DisableCloseButton

Whether or not the close button (X) will be disabled on screens. If this boolean variable is set to true the close button will be disabled. If the value is false (by default), it will be enabled. This variable can only be set from a project event such as On Startup. It will then affect any screens displayed after that point.

_PatchStages

A table of Boolean values that control whether certain patch stages are executed at runtime. Initially these values are set to true. If you want to skip a future patch stage, you can set its table entry to false. The patch stage table contains the following indexes that can be set:

 

"RunOnStartupActions"
"ShowBeforePatchingScreens"
"RunOnPrePatchActions"
"ShowWhilePatchingScreen"
"PatchFiles"
"RemoveLegacyFiles"
"RunOnPostPatchActions"
"ShowAfterPatchingScreens"
"RunOnShutdownActions"

Note: These values simply control whether or not the "stage" will be executed. This feature is mainly used for skipping stages.

_IR_ProductID

This variable contains the string "VP30" when used in Visual Patch. This allows you to identify the product being run from script.  This could be useful when making generic scripts that are used in several products, but that have different things to do based on the product being run from.

_NeedsReboot

Whether or not the system needs to be restarted at the end of the patch in order to replace files that were in use. This variable is initially set to false when the patch starts and is set to true if the system needs to be restarted.

Note: If the patch needs to be rebooted, a dialog prompt will be shown automatically asking whether or not a reboot should proceed. The dialog and reboot action that are automatically added to each project on the On Shutdown event are defined in the function g_HandleSystemReboot() which can be found in the global script file _Global_Functions.lua.

_ProgramFilesFolder

The user's Program Files folder (typically, this is something like "C:\Program Files").

_SilentPatch

Whether or not the patch should be run in "silent mode". Initially this value is set to the boolean value false, but if set to true the patch will be run silently.

In silent mode, no user interface is presented to the user at all; any screens or dialog messages will not be shown.

 

Note that although you can change the value of _SilentPatch at any time, you should only switch to or from silent mode on one of the four "main" action tabs:

On Startup

On Pre Patch

On Post Patch

On Shutdown

Changing the value of _SilentPatch at any other point will have no effect on any screens or progress displays until the next "main" action tab is reached.

Tip: This variable can also be set using the command line option /S or by selecting the Start in silent mode option at design time.

_SourceDrive

The drive that the patch executable was run from (e.g. "C:" or "D:").

_SourceFilename

The full path and filename of the patch executable (e.g. "C:\Downloads\patch.exe").

_SourceFolder

The full path to the folder that the patch executable was run from (e.g. "C:\Downloads" or "D:\").

_SystemFolder

The path to the user’s Windows System folder (e.g. "C:\Windows\System" on non-NT systems and "System32" on NT based systems).

_tblErrorMessages

A table indexed by error codes containing all of the possible error messages. For example, accessing the table index _tblErrorMessages[1000] will access the error code string "The specified file could not be found." The Application.GetLastError action is used to retrieve the last performed action's error code.

_TempFolder

The path to the user's Temp folder.

_TempLaunchFolder

The path to the temporary directory where Visual Patch extracts the files it will need for the patch. (For example, this is the directory where Primer files are extracted to.)

Usually this directory will be a subfolder of the user's temporary directory, unless overridden with the /T command line option.

_UseSystemCharacterSet

If set to true, Visual Patch will use the system's default character set (script) for text elements on screens when using custom fonts ("Use Custom Fonts" set to True), overriding it's font script setting. This makes the text font behave like Visual Patch's default settings when working with multiple languages. If you wish to use this variable, it's recommended that you set it very early in the patch. This variable defaults to false.

_WindowsFolder

The path to the user’s Windows folder (e.g. "C:\Windows").