Block description

The Variable block allows you to save and manipulate data values in your projects.Variables can be assigned a 4-character name and a value in the range -999 to 999.
Variables can be used in two ways:

  • As a conditional input block
    (When used within the head of a conditional block(If/While)
  • As a discrete block
    (Used for assigning a value to it, or incrementing/decrementing its value)

App interface and usage

As a discrete block

Variable blocks can be used as stand-alone blocks where they can be assigned values, or incremented or decremented.

Var Out 1
Once the block is dropped onto the canvas, you can use the Add button to assign a name for this variable.
If a variable already exists, you can select it for it to be used in and as this block.
Var Out 3
You can set a 4 character name for the variable created in the previous step.
Var Out 2

After you've set a name for this block, you can select the operator to be used with it.
Var Out Op
Here, you can assign a value to it, or increment/decrement it by 1.

If the assignment operator is used, you can assign to this variable , either a custom numeric value, or another existing variable (if present)
Custom
Var Out Custom
Var Out Cus Val
Variable
If an existing variable is present, you can assign it to the current variable.

As a conditional input block

A Variable block can also be used to check a condition inside the head of an If or While block as shown.
Var In Var 2

You can create a new variable using the Add button, or use an existing variable
Var In 1

If a new variable is added, it appears as below.
Var In 2

For this newly added block, you can select a comparison operator
Var In 2 Op

This block's value can be compared againsy a custom integer value or another existing variable.
Var In Custom
Var In Cust Val

Var In Var 2
Var In Var

Operations on Variable blocks

Deleting an instance of a Variable

An instance of a variable can be deleted from the canvas by using the Delete option in the Edit toolbar. This deletes only the current occurrence of the variable.
Delete Instance

Viewing the Variable declaration section

You can press the (X) icon on the project toolbar to view the details of variables used in the project.
The superscript indicates the number of variables in the project.
Decl

Deleting a variable

A variable can be deleted from the project by deleting it in the Variable Declaration section.
Decl
This deletes every instance of the variable through the project.

If this variable, say var1, was assigned to another variable var2, it is deleted from this instance , leaving the parent variable var1 assigned a blank value as shown.
Var Both 2

Renaming a variable:

A variable can only be renamed in the Variable Declaration section.
Decl

Guidelines

The total number of variables in the project can be viewed at the top of the canvas.
Clicking the X icon displays the Variable Declaration section.
You can use this section to rename or delete a variable throughout the project.

Example

  1. This example uses Variable block to check if the number of times motion is detected crosses 6. Once this happens, a notification is sent to GraspIO Studio.
    Example