/
Variables

Variables

Overview

A variable is a container for storing values that can be set statically or dinamically. One the key characteristics of a variable is that is subject to change during the life of an app.
Variables have names so the value in it can be referenced in one or multiple places easily. Let's see how to use it.

For this exercise we need to have a Project with at least one Page. Let’s continue using “HR App”.

How to declare a “Variable” in a page?

The first thing we need to do for using a variable is declare it. To do that let’s go to our HR Sample APP” project and open “Add Employee Form” Page.

Under page details expand the “General Information” section.

Let’s click on the "New" button.

A Popup will be displayed.

In the “Object Name” field let’s name the variable. We are going to call it “Message”.

The “Type” field sets the variable’s scope. We have two options:

  • Local: Variable’s scope is the current page.

  • Global: Variable scope is the entire application.

For now let’s use “Local”.

Now click on the “Data Binding” tab.

In the “Default” field we initialize the variable with a specific value. Set it to “Welcome to HR Sample App” and click on the “Submit” button to save changes.

Now we can see the new variable displayed under “Variables” tab:

How to use a variable?

We can reference variables using the ampersand (&) symbol at the left of a variable name.

Variables can be used in almost any value field in wayfast.

Variables can also be used as part of conditional statements. See conditional syntax reference if you want to know more about it.

In this example we will simply create a label and display the value contained in the variable.

Double click the Label and name it lblMessage.

In the “Default Value” field let’s enter “Main Title &” (without quotation marks) and click on the Submit button.

Keep in mind we can intersperse Variables anywhere in a given text and Wayfast will take care of replacing the variable’s name with its content.

Last, let’s click “Preview” to see it working.

Recap

Variables are a powerful feature that can be used almost anywhere to give your app a dynamic behavior by keeping states, controlling logical flows or sending them as parameters.
We will be seeing many more examples of variables in the rest of Control’s Unit.

Related content

Importing controls
Importing controls
Read with this
Button
Button
More like this
Search
Search
Read with this
Label
Label
More like this
Datasets
Datasets
Read with this
Controls
Controls
More like this