Perform operation on a variable¶
This action is important as it lets you manipulate the values of variables. You can initialize variables, modify the value of an existing one and perform additional operations on strings.
|Property Name||Data Type||Description|
|Operation||VarOps||Determines which action should be performed on the variable. See below for more information. There is a defined set of operations from which you can choose in the list box.|
|Separator||String||Defines the (separator) character for some operations. Optional.|
|Value||String||The new value to assign to the variable specified in "Variable". Required. This can be a "hard-coded" text or number, another variable or even a resource string.|
|Variable||VarName||Indicates the name of the variable to be changed. All variable names must be like this: %VARNAME%. Be sure to read the help topic regarding variables.|
All operations are Unicode-enabled. Remember that variables are limited in length to 4096 wide characters.
You can perform some operations on the value of the new or existing variable. Below is the description of each operation:
|varAssign||The variable will receive the value specified by the Value property. It may also be another variable.|
|varExtractFilename||Removes the path from the filename specified in Value. If you specified C:\TEMP\FILES.ZIP, then the variable will contain FILES.ZIP|
|varExtractFilePath||Like the operation above, the variable will receive the path from the filename, such as C:\TEMP|
|varExtractFileExt||The new variable will receive the extension extracted from the filename specified in Value. If you specified MYAPP.EXE, then the variable will contain .EXE.|
|varExtractFileDrive||Returns a string containing the drive portion of a fully qualified path name for the file passed in "Value". For file names with drive letters, the result is in the form |
|varRemoveFileExt||Removes the extension of the filename. Example: MYZIP.ZIP will become MYZIP|
|varDirectoryWOBS||To be used with variables that contain a path. This action removes the directory backslash from the end of the path if present. For example C:\My Documents will become C:\My Documents. Important: remember that all path variables in Paquet Builder do not have the directory backslash. For instance, %WIN% points to C:\Windows, not C:\Windows.|
|varDirectoryWBS||To be used with variables that contain a path. This action adds the directory backslash to the end of the path if missing. For example %SYS% will be evaluated to %SYS%.|
|varRemoveBeforeSep||Removes all characters before the separator specified in Separator.|
|varRemoveAfterSep||Removes all characters after the separator specified in Separator.|
|varGetShortFilename||The variable will receive the filename specified in Value converted into the 8.3 DOS filenames format.|
|varGetLongFilename||The variable will receive the filename specified in Value converted into the full Windows filename format (including the full path)|
|varReadValueFromClipboard||The package will retrieve the text from the Windows clipboard and set the resulting variable to it. If the contents of the clipboard is not text compatible, then the variable will be blank.|
|varStoreValueToClipboard||This action is special as it does not modify the variable itself: it actually reads the value of the Variable (the Value field is ignored) and stores it to the Windows clipboard. Imagine you want to put the text "It works!!" to the clipboard; you will need two "perform operation on a variable" custom actions: one to initialize a variable called "%VAR1%" to "It works!!" (select the varAssign operation) and then the second one to copy the text from %VAR1% to the clipboard (just enter %VAR1% in the Variable field, leave Value blank and select varStoreValueToClipboard as the Operation).|
|varReadEnvirVar||The resulting variable is set to the value read from the Windows environment variable specified by Value. For instance "TEMP" will return the default temporary folder.|
|varGetFreeSpaceOnDisk||Determines the free space in bytes available on the disk specified by Value. For example, if you enter C:\, the variable will get the total free space available on the C hard disk. Note that the value can also point to an existing folder.|
|varGetTotalSpaceOnDisk||Determines the total space in bytes available on the disk specified by Value. For example, if you enter C:\, the variable will get the total free and used space available on the C hard disk. Note that the value can also point to an existing folder.|
|varAddQuotes||Adds the quote character contained in Separator to the left and right of the string contained in Value. The result is then stored in the variable whose name is specified by Variable. Separator must point to a single-byte character such as " or < or '.|
|varStringReplace||Returns a string with occurrences of one substring (string1) replaced by another substring (string2). Variable indicated by "Variable" property is read and contains the original string with the (string1) substring. Separator should be set to string1 (the text you want to be replaced) and Value set to string2 (the new text). After replacement, Variable is updated: its value is set to the new returned string. See examples below. This function is not case-sensitive and will replace any occurrence of string1 by string2.|
|varNOTBool||To be used only with variables that contain a Boolean value (1 or 0). The variable will be set to the contrary of the specified value.|
|varANDBool||Applies the AND operator (conjunction) to a list of Boolean variables (2 or more required). Specify a list of variables in the "Value" field, each variable must be separated by a semicolon ; Example: |
|varORBool||Applies the OR operator (disjunction) to a list of Boolean variables (2 or more required). Specify a list of variables in the "Value" field, each variable must be separated by a semicolon ; Example: |
|varTrimSpaces||Removes all spaces located at the beginning and at the end of the contents in Value. Value can contain variables, resources strings and plain text. Result is stored into the variable indicated by "Variable".|
|varLength||Get the character length of the string in "Value" and store it into the variable indicated by "Variable".|
|varLeftString||Extract N characters from the left side of the string in "Value" and store it into the variable indicated by "Variable". N must be an integer and specified in "Separator".|
|varRightString||Extract N characters from the right side of the string in "Value" and store it into the variable indicated by "Variable". N must be an integer and specified in "Separator".|
The default operation is varAssign.
Examples for varStringReplace¶
You want to replace "
the" by "
a" in the following sentence: "
The mouse is eaten by the cat".
Create a variable named %MYSTRING% for instance and assign its value to "
The mouse is eaten by the cat".
Then add a "Perform operation on a variable" custom action with the following parameters:
Operation=varStringReplace Separator=the Value=a Variable=%MYSTRING%
You can then display the value of %MYSTRING% using a Show a message box custom action. You will get:
a mouse is eaten by a cat
\ character by
\\ (in C++ code for instance)
Enter the following parameters:
Operation=varStringReplace Separator=\ Value=\\ Variable=%MYRES2%
If %MYRES2% is set to
C:\Program Files\Paquet Builder\ for instance, you will get:
C:\\Program Files\\Paquet Builder\\\\