Variable

From webCoRE Wiki - Web-enabled Community's own Rule Engine
Revision as of 12:24, 12 November 2017 by Ipaterson (talk | contribs) (Described superglobals, global update behavior, initial value)
Jump to: navigation, search
Share on FacebookShare on TwitterShare on Google+Share on LinkedInShare on DiggShare on deliciousShare on redditShare on StumbleUpon

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.

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.