Variables and Values

<< Click to Display Table of Contents >>

Manual > Script Guide > Script Ver2 (SC2 syntax) >

Variables and Values

Variables and Values

Scripts can define and use variables - they are like containers for storing numbers, letters, Boolean values (TRUE/FALSE), etc.

The variable is "var" to the right of the declaration.= valueIf you specify ", it will be initialized to that value. Below is an example of how to declare it.

 

var a;
var a, b;
var a = 123;
var a = "Hello";

 

You can assign values to variables as many times as you like:

a = 1; // 1 is assigned to a
a = "hello"; // "hello" is assigned to a
a = 1 + 2 + 3; // 6 is assigned to a
a = a + 1; // the value of a plus 1 is assigned

 

 

Here is an example of using variables:

 

Example 1)

var a = 1; // a is set to the value 1
var b = 2; // b is set to the value 2
var x = a * 2 + b; // x is set to the value 4, which is the result of the calculation

 

 

Example 2)

var a = "Hello"; // a is set to the character "Hello"
var b = "World"; // b is set to the character "World"
var x = a + " " + b; // x is set to the result of the operation, "Hello World"

 

 

hint

For information on naming variables, see "Naming Rules".