> For the complete documentation index, see [llms.txt](https://mobsted-2.gitbook.io/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mobsted-2.gitbook.io/knowledge-base/references/intro-placeholder/variables.md).

# Variables

Variables store temporary data which can be used in any part of Mobsted platform. Variables can be used to:

* Hide/show screen elements depending on user actions \[Step by step example ->]
* Make math calculations based on user input \[Step by step example ->]
* Display API operations results depending on user input \[Step by step example ->]

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

#### SETTING UP VARIABLE

Variables are set as integer or string value to[ Button](/knowledge-base/references/intro-placeholder/constructor_elements.md#button)/[Link](/knowledge-base/references/intro-placeholder/constructor_elements.md#link)/[Image](/knowledge-base/references/intro-placeholder/constructor_elements.md#image)/[Text](/knowledge-base/references/intro-placeholder/constructor_elements.md#text) elements and to [Screen](https://mobsted-2.gitbook.io/knowledge-base/screens). This is done in properties in **Constructor:**&#x20;

1. Add **Button**, **Link**, **Image** elemet to screen or select any **Screen** you have in the bottom of Constructor
2. Click **Actions** in **Properties** panel
3. Select **Set Variable** from the dropdown
4. &#x20;Assign one or several  **Name** and **Value** pairs
5. Click **Save.**

![](https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoP8IKlEFq1udd7TMV6%2F-LoPExCldYrgwHGiRqha%2Fvariables.png?alt=media\&token=d509e0f8-b0ad-4fde-bac6-4e7478bfc033)

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

#### CALLING VARIABLE

Variables can be called in any part of the platform by using Hashtags.

![](https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoyhUJFPXgw5gCz1B7T%2F-LoyhY1DU4o0IKTKwoRz%2Fezgif.com-video-to-gif%20\(4\).gif?alt=media\&token=740d8243-eeec-4fd4-9fe5-9de1143e0323)

####

#### \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

#### **USE VARIABLES TO HIDE/SHOW SCREEN ELEMENTS**

**\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_**

#### **USE VARIABLES IN MATH CALCULATIONS**

**\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_**

#### **USE VARIBALES IN API OPERATIONS**&#x20;

We have Weather check app where a user gets current temperature information on entering a city. The temperature information is recieved from [apixu.com](https://kb.mobsted.com/article/apixu.com) service via [API operation](/knowledge-base/basics/introduction/use_any_internal_and_external_api.md).&#x20;

<div align="left"><img src="https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-Lp8ECjr9gvaCTlzuEqH%2F-Lp8EJn0CYlPXxIc0EqP%2Fezgif.com-video-to-gif%20(5).gif?alt=media&amp;token=bfe0c1e2-dd42-4a11-98ea-b0cc01d01a32" alt=""></div>

####

We have Water delivery app where you can select bottle size and quantity. You can also see the summary of your order upon order confirmation. We use variables to hide/show elements and for calculations.&#x20;

App basic logic:

* When a size button is clicked, it is replaced with white to indicate selection
* If the size button is clicked again, it is replaced with blue to indicate deselection
* When one size is already selected and another size button is clicked, the the first button is deselected automatically
* When the order is confirmed, order information appears on the screen.&#x20;

![](https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoyReKTB8WNPCXV7kQf%2F-LoyRjD5vsInJhDQdo5D%2Fezgif.com-video-to-gif%20\(3\).gif?alt=media\&token=0c3c16d8-a238-42c7-a31a-e7afb48fa178)

**How it was set up:**

1. We created pairs of buttons for each size: blue and white.&#x20;

**For blue buttons:**&#x20;

* Set **Variable** with **Name/Value** pairs:&#x20;
  * Selected\*size\* = 1. The variable is set to 1 on button click.&#x20;
  * Selected \*other size\* = 0. When one button is selected all other buttons are deselected.&#x20;
  * size = bottle size
  * price = amount&#x20;

Example: set up for blue buton 12 OZ.&#x20;

<div align="left"><img src="https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoyWJV-pAvAbjqZJHnV%2F-LoyX-MoJ_CC1cbTx-oc%2Fvar%20222.png?alt=media&amp;token=56a3419d-3952-4a6b-951a-eff35bea154d" alt=""></div>

* Set **Visibility** conditions: #Variable:selected\*size\* = 0.  The button is visible when not selected.&#x20;

![](https://storage.googleapis.com/helpdocs-assets/jyme83anlw/other/1567577559572/image.png)<br>

**For white buttons:**&#x20;

* Set **Variable** with **Name/Value** pairs:&#x20;
  * Selected\*size\* = 0. The variable is set to 0 on button click.&#x20;
* Set **Visibility** conditions: #Variable:selected\*size\*# = 1. The button is visible when selected. \
  ![](https://storage.googleapis.com/helpdocs-assets/jyme83anlw/other/1567577522185/image.png)

2\. [Select](/knowledge-base/references/intro-placeholder/constructor_elements.md#select) element contains drop down with quantity. It's Backendname is set as **amount** which is used for calculation the amount to be paid.&#x20;

&#x33;**. Confirm** button **Variable** set with **Name/Value** pair:

* **total** = =(#Variable:price# \* #Backendname:amount#)=.

[Math formula](/knowledge-base/basics/introduction/use_math_formulas.md) in **Value** field calls out  #Variable:price# set for the selected button.&#x20;

<div align="left"><img src="https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoyWJV-pAvAbjqZJHnV%2F-LoydvX4yZZx4EV1fbZP%2Fvar555.png?alt=media&amp;token=61675dd7-0614-484e-ad76-68c60cf8a67a" alt=""></div>

4\. **Text** element calls out **Variables:**&#x20;

* \#Variable:size# from the selected size button
* \#Variable:total# result of calculation from **Confirm** button.

<div align="left"><img src="https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoyWJV-pAvAbjqZJHnV%2F-LoybCuGR2-Iku7QE5KM%2Fvar%20333.png?alt=media&amp;token=89232b32-08df-4a46-805a-2ef5819b5465" alt=""></div>

App user view:&#x20;

<div align="left"><img src="https://877328951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlgISQGimMcecefzSf2%2F-LoykxzsO1WBU2J5Rggy%2F-Loylo1k0lxxaGSDNbfz%2Fvar444.png?alt=media&amp;token=a8bba64b-424c-4578-bc7a-1ec022fca5d0" alt=""></div>

#### MENTIONED ARTICLES

* [Constructor elements](/knowledge-base/references/intro-placeholder/constructor_elements.md)
* [Hashtags](broken://pages/-Lng8YhcijvNwU_6pHum)
* [Use MathJS formulas](/knowledge-base/basics/introduction/use_math_formulas.md)
