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

OperationVarOpsDetermines which action should be performed on the variable. See below for more information. There is a defined set of operations from which you 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.
VariableVarNameIndicates 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.

You can perform some operations on the value of the new or existing variable. Below is the description of each operation:

Operation Name

Description

varAddQuotesAdds 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 '. MBCS compatible.
varANDBoolApplies 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 with a not comma ;
Example: "%BOOLVAR1%;%BOOLVAR2%;%BOOLVAR3%" (without the quotes) will perform the following operation:
%BOOLVAR1% AND %BOOLVAR2% AND %BOOLVAR3%

AND: an expression of the form X and Y is True if and only if both X and Y are True.

The result is also a Boolean variable (remember that, in Paquet Builder, Boolean variables are represented by 1 for true and 0 for false.

varAssign

The variable will receive the value specified by the Value property. It may also be another variable.

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%\.

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\.

varExtractFileDriveReturns 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 '<drive>'. For file names with a UNC path the result is in the form '\\<servername>\<sharename>'. If the given path contains neither style of path prefix, the result is an empty string.

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.

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

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.

varGetLongFilename

The variable will receive the filename specified in Value converted into the full Windows filename format (including the full path)

varGetShortFilename

The variable will receive the filename specified in Value converted into the 8.3 DOS filenames format.

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.
varORBoolApplies 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 with a not comma ;
Example: "%BOOLVAR1%;%BOOLVAR2%;%BOOLVAR3%" (without the quotes) will perform the following operation:
%BOOLVAR1% OR %BOOLVAR2% OR %BOOLVAR3%

OR: an expression of the form X or Y is True if X is True or Y is True or if both are True.

The result is also a Boolean variable (remember that, in Paquet Builder, Boolean variables are represented by 1 for true and 0 for false.

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.

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.

varRemoveAfterSep

Removes all characters after the separator specified in Separator.

varRemoveBeforeSep

Removes all characters before the separator specified in Separator.

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).

 

varStringReplaceReturns a string with occurrences of one substring (string1) replaced by another substring (string2). Value indicates the original string containing the (string1) substring. Separator contains the string1 and string2 substrings in this format: "string1","string2" and finally Variable contains the name of the variable whose value will be set the the new returned string. See examples below.

This function is not case-sensitive, MBCS-aware and will replace any occurrence of string1 by string2.

The default operation is varAssign.

Examples for varStringReplace:

  1. You want to replace "the" by "a" in the following sentence: "The mouse is eaten by the cat".
    Enter the following parameters:
    Operation=varStringReplace
    Separator="the","a"
    Value=The mouse is eaten by the cat
    Variable=%MYRES%

    You can then display the value of %MYRES% using a Show a message box custom action. You will get: a mouse is eaten by a cat

  2. Replacing the "\" character by "\\" (in C++ for instance).
    Enter the following parameters:
    Operation=varStringReplace
    Separator="\","\\"
    Value=C:\Program Files\Paquet Builder\
    Variable=%MYRES2%

    You will get: C:\\Program Files\\Paquet Builder\\


  Paquet Builder Help - Copyright © G.D.G. Software. All rights reserved.