This activity lets you create and modify variables. They store the set value and can be used in other activities.
General usage of this activity:
- Set the name and value. For example, we have a variable named login_message and its value is some text like You have successfully logged in.
- Use this variable in other activities. For example, use it with ‘Save the previous step result’ in different activities.
Let us review its parameters.
Variable name and value
Variable name is pretty self-explanatory. You can name variables as you see fit, but there are some restrictions and things to remember:
- The first symbol in the name must be a Latin character or underscore (_).
- The rest of the name can include any Latin letter, digit or underscore.
- Avoid using $ symbol at the beginning and at the end of the name. Such names are reserved for ElectroNeek platform internal variables.
- Variable names are case sensitive.
- All the variables declared in this block are global. This means that a variable can be used in any other .neek files.
In this example message is the name of the variable.
There is also a dropdown list that lets you choose the variable that is handled by the selected block.
Dropdown list containing other created variables
For example, we have these two variables - message and message2.
Two variables containing some text in the workflow
Currently the lower block (containing message) is selected, and this is what we see. These parameters are set for message variable.
Parameters of message variable
What if we change Variable name from message to message2 in this list? This is what will happen.
Redefinition of variable value
This output message shows that the new value was used
Basically, we have redefined the message2 variable. It can be seen in the output if we try to display the result in the console using ‘Console log’ activity. This could come in handy in some situations.
Now let us move to Variable value parameter. Similar to many other activities, it offers a few options:
Set a value lets you input the value manually. In this case the type is automatically switched between Text and Number based on the input. Examples: Some text, 122.
Calculate a value lets you use JS to define a specific value. Example: some_variable * 2, someArray.length.
Save the previous step result lets you set the variable value using the result or output of the previous activity block.