Variables

A variable is a mechanism that allows you to store, modify and reuse a value defined by the user or for the application (a number, text etc..). This value affects the user interface in some way at a given time. 

Here are some use cases: store and display the user's score, know if the user has already opened the application or not, store a color code, save a user's selection... 

Variables allow you to add more customization in your application and set up logical scenarios with the conditions.

In this article

What is a variable?

A variable associates a name with a value that can change.

Choose the name of the variable: it must be unique, composed of alphanumeric characters, and it must allow you to understand its use explicitly. For example:  score to store the user's score or selected_item to store the identifier of an item selected by the user.

Once your variable is created, you can associate a default value with it, change its value from any trigger and display it in the interface.

When you create a variable via the PandaSuite database, this variable is local: it is stored only on the user's device. It is persistent even after closing the application. However, it is not possible to access it if the user uses another device or to know its value outside the application.

💡You can also create a variable associated with a user using the Firebase Session component. In this case, it is possible to get the value of this variable and/or to edit it from the Firebase interface. If the user uses another device, his account remains associated with this variable. 

Create a variable

To create a variable, add a PandaSuite database. Click the Add property

Choose the name of your variable and its type:  BooleanNumberText, Table... You can choose a default value. 

Edit the value of a variable

You can change the value of a variable at any time and from any action in your user interface: when a screen is displayed, when a button is clicked etc... 

Select your trigger and the action Interact with a component. Select your data source (PandaSuite database) and the action Modify the data

Choose from the functions available:  DefineIncrementDecrementAddDelete.

In the example below, the identifier of the current element is added within the variable saved_items (for the bookmarking).

Display the value of a variable

Thanks to data binding, you can display the value of your variable. Let's take the example of a score.
Insert a text block and click on Source. Choose From a database.

💡 Learn about a concrete use case for a variable: Score

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us