Ask AI
Skip to main content

Create a number

Function: Create a number

This action allows you to create a new variable in your application's memory (called the "variable scope") and assign a numerical value to it. This is useful for storing temporary calculations, counters, or any numerical data that your application needs to use or modify during its execution.

Input

  • Value (NUMBER): The numerical value you want to store in the new variable. If you don't provide a value, it will default to 0.

Output

  • Variable name (NUMBER): A unique numerical identifier that represents the name of the variable that was just created. You can use this identifier to refer to the variable later in your application.

Execution Flow

Real-Life Examples

Here are some examples of how you can use the "Create a number" action:

Example 1: Initializing a Counter

Imagine you want to count how many times a user clicks a button. You can start by creating a variable to hold this count.

  • Inputs:
    • Value: 0
  • Result: A new variable is created in your application's scope with the value 0. The action outputs a number, for instance, 101, which is the unique identifier (Variable name) for this new counter variable. You can then use this 101 to refer to your counter.

Example 2: Storing a Calculated Price

Suppose you have a product price that needs to be stored for further calculations.

  • Inputs:
    • Value: 49.99
  • Result: A new variable is created holding the value 49.99. The action outputs a number, such as 205, which is the unique identifier (Variable name) for this price variable.

Example 3: Setting a Default Quantity

When a user adds an item to a cart, you might want to set a default quantity.

  • Inputs:
    • Value: 1
  • Result: A new variable is created with the value 1. The action outputs a number, for example, 310, which is the unique identifier (Variable name) for this quantity variable.