# Storage (/ink/storage)



<CalloutContainer type="info">
  <CalloutDescription>
    You can read more about using variables in ink on the [official documentation](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#part-3-variables-and-logic).
  </CalloutDescription>
</CalloutContainer>

***ink*** also supports variables, both temporary and global, storing numerical and content data, or even story flow commands. It is fully-featured in terms of logic, and contains a few additional structures to help keep the often complex logic of a branching story better organised.

In the ***ink* + Pixi’VN integration**, the variables `VAR` and `CONST` are equivalent to <DynamicLink href="/start/storage">variables in storage</DynamicLink> and the variables `temp` are equivalent to <DynamicLink href="/start/storage#temporary-storage">temporary variables in storage</DynamicLink>.

The name of the &#x2A;**ink*** variables corresponds to the key of a variable in the <DynamicLink href="/start/storage">storage</DynamicLink>.

## Define [#define]

<CalloutContainer type="info">
  <CalloutDescription>
    This functionality in Javascript/TypeScript corresponds to <DynamicLink href="/start/storage#default-storage-variables">"Default storage variables"</DynamicLink>.
  </CalloutDescription>
</CalloutContainer>

You can define a variable in &#x2A;**ink*** with the following code:

<CodeBlockTabs defaultValue="ink">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="ink">
      ink
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="CLI">
      CLI
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="ink">
    ```ink
    VAR myVariable = 42
    ```
  </CodeBlockTab>

  <CodeBlockTab value="CLI">
    ```txt
    VAR <variable_name> = <value>

    where:
        variable_name = the name of the variable
        value = the initial value of the variable
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Set [#set]

<CalloutContainer type="info">
  <CalloutDescription>
    This functionality in Javascript/TypeScript corresponds to <DynamicLink href="/start/storage#set">`storage.set`</DynamicLink>.
  </CalloutDescription>
</CalloutContainer>

You can set a variable in &#x2A;**ink*** with the following code:

<CodeBlockTabs defaultValue="ink">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="ink">
      ink
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="CLI">
      CLI
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="ink">
    ```ink
    ~ myVariable = 100
    ```
  </CodeBlockTab>

  <CodeBlockTab value="CLI">
    ```txt
    ~ <variable_name> = <value>

    where:
        variable_name = the name of an already declared variable
        value = the new value to assign
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Get [#get]

<CalloutContainer type="info">
  <CalloutDescription>
    This functionality in Javascript/TypeScript corresponds to <DynamicLink href="/start/storage#get">`storage.get`</DynamicLink>.
  </CalloutDescription>
</CalloutContainer>

In ink, variables can be used for different purposes. For each of these purposes, the way to get the value of a variable is different.

<CodeBlockTabs defaultValue="ink">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="ink">
      ink
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="CLI">
      CLI
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="ink">
    ```ink
    The value of myDuration is: {myDuration}
    ```
  </CodeBlockTab>

  <CodeBlockTab value="CLI">
    ```txt
    {<variable_name>}

    where:
        variable_name = the name of the variable to print or evaluate
    ```
  </CodeBlockTab>
</CodeBlockTabs>

For example:

```ink title="ink"
The value of myDuration is: {myDuration}
# show image bg /image.png with dissolve duration {myDuration}
{myDuration > 5:
    The duration is greater than 5.
- else:
    The duration is 5 or less.
}
```
