# get

## Description

Returns the value of a global variable.

## Input / Parameter

| Name         | Description                        | Input Type  | Default | Options | Required |
| ------------ | ---------------------------------- | ----------- | ------- | ------- | -------- |
| name         | The name of the variable.          | String/Text | -       | -       | Yes      |
| defaultValue | The default value of the variable. | String/Text | -       | -       | No       |

## Output

| Description                                                                                               | Output Type |
| --------------------------------------------------------------------------------------------------------- | ----------- |
| Returns the value of the global variable if there is a value, returns the `defaultValue` value otherwise. | String/Text |

## Example

In this example, we will get the value of a global variable and print it in the console.

### Steps

1. Drag a `button` component into the canvas and open the `Action` tab. Select the `press` event of the button and drag the `Log.write` function to the event flow.
2. Call the function `Variable.get` inside the `Log.write` function. (\*Note: The `Log.write` function is used here for ease of demostrating the output.)
3. Specify the variable name that you would like to access.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9bd8382b438648298271a855c04843e04bcd81f3%2Fget-step-1.png?alt=media)

### Result

1. If the specified global variable has previously been set (see [`set`](https://github.com/OrangeKloud/emobiq-documentation/blob/master/document/client/006-actions-and-visual-logic/action-reference/react-native/Variable/get/set/README.md)), the function will return the variable's value ("1.0.0" in this example).

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-89a7c4b93a41f40e1df9ee1d9b9960538d885ca9%2Fget-result-1.png?alt=media)
2. If the specified global variable does not exist, the function will return the value in `defaultValue`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-4fa7bbf40fc30da735e3d6d78a82b16a9dfdd7d8%2Fget-result-2.png?alt=media)

## Links

### Related Information

See also:

* Functions
  * [Variable.set](https://github.com/OrangeKloud/emobiq-documentation/blob/master/document/client/2-5-actions-and-visual-logic/action-reference/react-native/Variable/set/set.md)
