Working with variables¶
Variables are essential in Paquet Builder as they enable flexibility by holding changeable values and adapting to different environments. Here's a detailed guide on understanding and using variables in your projects.
What is a Variable?¶
Variables are named containers that hold dynamic values, which can be system-related information, user inputs, or calculated results. These values can change during the package's execution.
Example: %USERPROFILE%
might hold the path to the user's home directory.
Characteristics of Variables in Paquet Builder¶
▶️ Naming Rules:
- Must begin and end with
%
. - Cannot contain special characters like
#
,$
,"
. - Use only letters, numbers, and underscores (
_
). - Example:
%MY_VARIABLE%
is valid, but%MY VARIABLE%
is not.
▶️ Data Type: Hold Unicode text.
▶️ Reserved Names: Variables starting with PB
are reserved for internal use.
▶️ Length Limit: Maximum length is 4096 wide characters.
Using Variables in Your Package¶
Variables are used in custom actions to build messages, set file locations, or define conditions. They are replaced by their assigned values during execution. For instance: %WIN%
might be replaced with the Windows directory path.
Boolean Variables¶
- Definition: Variables that can only have values
1
(true) or0
(false). - Use: Often employed in conditional blocks, e.g., for managing components or operations based on conditions.
Managing Variables with the Variable Manager¶
Access the Variable Manager via the ribbon:
The Variable Manager helps maintain a list of variables, ensuring consistency and ease of reference across your project.
Steps to Define a Custom Variable:¶
- Click "Add": Opens the variable editor.
- Set the Name: Ensure uniqueness within the project.
- Assign a Type: Use predefined types like "Path," "String," or "Boolean" for organization.
- Add Comments (Optional): Helpful for documentation.
- Remove Variables: Custom variables can be deleted as needed.
Global (Predefined) Variables¶
Paquet Builder provides several global variables pre-set with system and user information.
Examples:
-
%WIN%
: Path to the Windows directory. -
%PROGRAMFILES%
: Path to the Program Files directory.
Refer to the list of global variables for more information.
Tips for Variable Usage¶
- Use
%
around variable names for substitution. - Boolean variables simplify conditional logic in custom actions.
- Avoid starting custom variable names with
PB
to prevent conflicts with reserved variables.
For detailed examples and advanced uses, explore the custom actions documentation.