Declare Variables

You must declare a variable before it can be used. You do this using the var keyword as follows:

var x;
var radius;
var name;

You can declare more than one variable at a time by listing more than one variable name in the var statement.

var x,radius,name;

When you create a variable, it is initially assigned the value null. You can explicitly assign a different value to the variable by supplying an initializer in the var statement as follows:

var x=0,radius=23.2;
var name="DScript";

Variable values are case-sensitive.

See Case Sensitivity in DScript.

One aspect of DScript that is different from some programming languages is that you do not declare the type of data the variable can hold. This is because every variable can hold any type of data. You can even change the type of data the variable holds from one statement to the next.

For example, you can assign a number to a variable in one statement and then later change the variable’s value to a text string.

Variable Examples

Variable Example Meaning
var x; // declare variable x
x=5; // x holds numeric data
x="some text"; // x data type changed to text