Difference between revisions of "Variable"

From webCoRE Wiki - Web-enabled Community's own Rule Engine
Jump to: navigation, search
(Variable Data Types)
(Global Variables)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[some info on variables]
+
A ''variable'' is a container for data that can be referenced or modified at a later time. Common uses of variables include
  
==Variable types==
+
* Tracking a value for use in the future
 +
* Communicating or tracking state between pistons
 +
* Avoiding repetitive code by storing data that needs to be used in multiple places in a piston
 +
 
 +
 
 +
==Variable scopes==
 
===Local Variables===
 
===Local Variables===
Local variables are variables that are owned by an individual piston. They are unique to each piston and are not shared among pistons. Multiple pistons can define local variables with the same name, they do not overlap.
+
Local variables are owned by an individual piston. They are unique to each piston and are not shared, so multiple pistons can safely define local variables with the same name.
 +
 
 +
The ''Show variables'' option in the piston editor enables a <code>define</code> block where variables are added. Local variables can have an ''initial value'' that is set every time the piston runs. If omitted, any value set to the variable will carry over for use in future executions of the piston.
  
 
===Global Variables===
 
===Global Variables===
Global variables are variables that are common to all pistons. They always start with the @ symbol and are available to any and all pistons. Any change made to a global variable by any piston is immediately available to all other pistons within the same webCoRE instance.
+
Global variables are variables that are common to all pistons. They always start with the @ symbol and are available to all pistons in the same webCoRE instance.
 +
 
 +
Any change made to a global variable by any piston is available for the next run of all other pistons within the same webCoRE instance. When a piston runs, a snapshot is taken of the global variables to ensure that they do not change unexpectedly while the piston is executing. For this reason, global variables cannot be used to "pass back a result" from the Execute piston action to its caller.
 +
 
 +
 
 +
Note: Define global variables on the upper right hand pane while editing a piston.
 +
 
 +
===Superglobal Variables===
 +
Users with more than one webCoRE instance at a single location can share superglobal variables between those webCoRE instances. Use the @@ prefix to create a superglobal variable.
  
===System Variables===
+
==System Variables==
System variables are local read-only variables that provide information about the environment. They cannot be written to and their values are not necessarily constant (the same) during the whole piston run
+
System variables are local read-only variables that provide information about the environment and always have a $ prefix. They cannot be written to and their values are not necessarily constant (the same) during the whole piston run.
  
 
==Variable Data Types==
 
==Variable Data Types==
webCoRE supports a variety of data types, please review the [[Variable Data Types|variable data types]].
+
webCoRE supports a variety of data types, please review the [[Variable data types|variable data types]].

Latest revision as of 15:27, 12 September 2018

A variable is a container for data that can be referenced or modified at a later time. Common uses of variables include

  • Tracking a value for use in the future
  • Communicating or tracking state between pistons
  • Avoiding repetitive code by storing data that needs to be used in multiple places in a piston


Variable scopes

Local Variables

Local variables are owned by an individual piston. They are unique to each piston and are not shared, so multiple pistons can safely define local variables with the same name.

The Show variables option in the piston editor enables a define block where variables are added. Local variables can have an initial value that is set every time the piston runs. If omitted, any value set to the variable will carry over for use in future executions of the piston.

Global Variables

Global variables are variables that are common to all pistons. They always start with the @ symbol and are available to all pistons in the same webCoRE instance.

Any change made to a global variable by any piston is available for the next run of all other pistons within the same webCoRE instance. When a piston runs, a snapshot is taken of the global variables to ensure that they do not change unexpectedly while the piston is executing. For this reason, global variables cannot be used to "pass back a result" from the Execute piston action to its caller.


Note: Define global variables on the upper right hand pane while editing a piston.

Superglobal Variables

Users with more than one webCoRE instance at a single location can share superglobal variables between those webCoRE instances. Use the @@ prefix to create a superglobal variable.

System Variables

System variables are local read-only variables that provide information about the environment and always have a $ prefix. They cannot be written to and their values are not necessarily constant (the same) during the whole piston run.

Variable Data Types

webCoRE supports a variety of data types, please review the variable data types.