Script Variables

Contents





Overview


Variables are expressions that you can use to store a value that can be changed as needed.

These variables can be used to avoid fixed settings and keep the script language as dynamic as possible. This also makes your script become portable and work under any path or quickly change script settings when needed.

We can group variable into 3 categories, Fixed, Custom, and Runtime, each one having a specific sequence which we detail over the next chapter.


Usage

Variables are meant to be used inside your commands while your script is running.

They allow you to make changes at a global level. Changing the value of single variable can change the way how the whole project is built.

When a project starts to run - a list of variables is created using this specific order level
  1. Fixed variables
  2. Custom Variables
  3. Runtime variables

If needed, we can overwrite a variable with a new value, meaning for example that a fixed variable can start with a value which can later be changed if we add a variable with the same name on our script, overriding the previous fixed value.

This is only valid while this script is running and these changes will be removed when running another script.

These explanations may seem complicated now but it's simple to understand once you follow each one of the chapters below. You don't have to worry much about this information until you decide to begin coding your own scripts in a more efficient way. In either case, it will be detailed here should you need it one day.


Fixed Variables

These variables are created by default just before a project start to run.

WinBuilder retrieves information found inside your Operating System and a few others definitions related to your project settings.

Date related (output present date settings)

User environment variables
WinBuilder specific

Project specific


Custom Variables

These are additional variables that can be added by script authors.


How to create them?

Place a section called [variables] and write your variables in INI style. It is not obligatory to use the percentage (%), we just use this method for labeling it as a variable.

Example

[variables]
%workdir%=c:\myPath
%project_title%="My Boot Disk"

For this example we are creating two variables, available while the script is running, which can be used inside script commands.


This [variables] section can be placed in 3 different files, each one with a different scale of availability.





Runtime Variables

These are the type of variables that are created while the script is running. This means that you can create your own local variables whenever needed.

To specifically create new variables you can use  these script commands:


There's a small trick that you can also use to create new runtime variables. Whenever you use any command that uses a variable to store the result a new variable will be added to the list if it didn't existed before.

Applies to:


One last detail - the run command also uses runtime variables that we can use to pass parameters to another section. These variables use numbers from #1 to #9. You should always check the values that are being used in each of these variables to ensure that everything works as you expect.



Frequently Asked Questions

Q: I'm still a bit confused, how can I understand this better?
A: Look inside a project folder and open up the script.project file with notepad to view good examples. This also applies to WinBuilder.ini (same folder as WinBuilder.exe) and to your script files.

Q:
I'm doing my own script - how can I know if the value of my variables is right?
A: Use commands to output show the variables on the log. Echo,%myVar% is a good example to help in this case.

Q:
I know that we don't need to %% on each variable we create - are there any restrictions about what I can and cannot use?
A: You should only be careful to choose titles that aren't confused with other commands or variables, try using distinct titles that identify the variable purpose.

Q:
Also heard that variables can replace commands, is this true?
A: Variables can't directly replace commands but can be used to run sections with new specific functions. Look on the script applications page for details about this sort of use.




Bugs


There are a few known issues with variables that you should be aware.


Please let us know if this page is not complete or if you still haven't found needed information.