Variables

Define and store user-specific values such as number of points, page progression, number of sessions, etc. These variables can then be reused in your application for display or as a trigger for an action.

This notion of variable is useful for games, but more globally as soon as your application interacts with the user according to his behavior.

To create a variable, you can use the data provider (only available to Pro users). These variables are persistent even after closing the application.

What is a variable?

A variable associates a unique identifier with a value that can change.
Here are the steps to create a variable : 
  • Go to the data provider and create a new Property.
  • Rename this property with a unique identifier.
  • Choose its type: number, boolean...
  • Define a default value. 
This value is ready to be used in your application. Let's look at two examples: the "is_first_time" variable and the "score" variable. 

The "is_first_time" variable to skip screen after first use

This variable will allow us to know if the user has already opened the application or not. This can be useful to skip the onboarding screen after the first use.

Create the "is_first_time" variable

Go to the Data Provider and create a new Property
Rename this property: is_first_time
It is of Boolean type and has a default value of True.

Change value after first use

This variable will be converted to False when the first screen is displayed for the first time. This is how we will know if the user has already visited the application. 
Select the home screen.
Click on Actions.
When the screen is displayed, select the action Interact with a component > select the data provider and the action Modify data. Here are the parameters of your action : 
Data: /is_first_time<br>Function: Set<br>Value: False

Change screen with the variable

Now let's automatically go to the next screen if the user has already consulted the application.
To do this, you have to create a condition if the value is False (if is_first_time is False)

Create condition

Insert a Condition component. 

From the Properties window, choose At least one and uncheck the Live evaluation option so that the screen change is not too sudden. Here are the settings of the expression:

Data: [data:ID_BDD(/is_first_time)]
Function: Equal 
Value: False
To find the data provider identifier, please refer to the article on Dynamic Data.

Evaluate condition

This condition will be evaluated when the screen is displayed. Create an action at screen display > Interact with a component > Conditions > Evaluate the condition.

Trigger action

Create the action of changing the screen. Select the Condition component and as a trigger, Evaluation of the condition. Choose Go to the selected screen for Screen 2.

The "score" variable to record and display a result

The variable "score" is for example used for a quiz. Let's imagine a quiz with 20 questions, each question gets one point. The objective is to increment the score with the right answers and to display the user's final score.
If you are creating a personality test, all you have to do is establish a point structure based on the answers to create a profile (if more than 50 points, you are...; between 20 and 50 points, you are...; less than 20 points, you are...; if more than 50 points, you are...; between 20 and 50 points, you are...; less than 20 points, you are...).

Create the "score" variable

Go to the  Data Provider and create a new  Property
Rename this property:  score
It is of Number type and has a default value of  0.

Increment value

Prepare the questions and answers, and the links between the different questions.
For correct answers, you need to increment the score value.
Select the correct answer and click on Actions.
Choose the action Interact with a component > select the data provider and the action Modify data. Here are the parameters of your action: 
Data: /score 
Function: Increment
Value: 1

Display "score" final value

Now let's display the score result at the end of the quiz, i.e. the final value of the variable "score". 
Prepare your final screen. Insert a block of text that will represent the number of points. 
In the Properties window, click on the Dynamic Data icon and the Add > Text button.

Replace my-bind by: 

[data:ID_BDD(/score)]

Still need help? Contact Us Contact Us