"Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. This data can then be used throughout your program."
Drag the Create Variable module into your program flow diagram.
WayScript will automatically display the Settings Panel for your Create Variable step. This is where you are going to set up your variable.
For this example, we are going to assign a Variable Name called "Location" and set the Variable Value to "Brooklyn, NY". Feel free to put in your own location instead.
After setup, your new variable will appear in the Variables Panel. You can now use this variable in your program.
Your variable is is available for reference at any future step in your program flow. In this example, we can now print a message which contains the Location variable.
You can begin typing the variable name to select it, or you can drag the variable from the Variable Panel into the Content to Print input.
A list (also called an array) is a data structure used to store multiple pieces of information in an ordered sequence where each has a unique 'position' (also called index) in the list. List variables can even store other variables.
In your Create Variable Settings, change your mode to a List of Items.
In this example, we'll create a list with Variable Name "Grocery List" and add items as Variable Values. The use cases for lists will be discussed more in the Looping **section of the docs.
Your Grocery List is now a variable that can be used in your program.
Variables can have the following types:
You explicitly define the type of your variables. Note - if you are building a List - the variable type defines the type of data in each list item. WayScript performs type validation on each of your items. As an example, if you create a Number Type, but set your variable value to a non-number, the value will be rejected. This is important because many modules often only accept inputs of particular types.
If you know some coding, you can more rapidly build a variable from the module shortcut dropdown by entering the definition directly.
This power-user features matches the syntax of the Python programming language for strings and arrays.