You have to declare variables explicitly in your scripts using the Dim statement (paxBasic) or Var statement (paxC, paxPascal). These statements create variables.
Variables are initialised to Undefined when created. But you can assign the variable with another value. For example:
paxBasic:
Dim X As String = "abc" Dim Y = [100, 200] Dim Z = new MyNamespace.AClass()
paxC:
string X = "abc"; var Y = [100, 200]; var Z = new MyNamespace.AClass();
paxPascal:
Here Y has been assigned by the zero-based array which contains 2 elements. The variable Z above was assigned by object.var X: String = 'abc'; Y = [100, 200]; Z = MyNamespace.AClass.Create();
You can create a multi-dimensional zero-based arrays without having to initialise it. For example:
Dim X(10, 4) 'paxBasic
var X[10, 4]; //paxC, paxPascalIn a two-dimensional array, the first number is always the number of rows; the second number is the number of columns.
When you declare a variable within a procedure, only code within that procedure can access or change the value of that variable. It has local scope and is a procedure-level variable.
When you declare a variable within a class body, only code within that class can access or change the value of that variable. Besides you make it recognizable to all the methods in the class with the following exception: if the variable was declared as non-shared one, it is not recognizable to all shared methods in the class.
When you declare a variable within a namespace, only code within that namespace can access or change the value of that variable. Besides you make it recognizable to all the classes and their methods in the namespace.
If you declare a variable outside all procedures, namespaces and classes, you make it recognizable to all the procedures and methods in your script. This is a script-level variable, and it has script-level scope.
Namespace Shapes Dim ShapeCount, ShapeList[100] Sub RegisterShape(S) ShapeCount += 1 ShapeList[ShapeCount] = S End Sub Class Point Dim X, Y Sub New(X, Y) Me.X = X Me.Y = Y RegisterShape(Me) End Sub End Class Class Square Dim X1, Y1, X2, Y2 Sub New(X1, Y1, X2, Y2) Me.X1 = X1 Me.Y1 = Y1 Me.X2 = X2 Me.Y2 = Y2 RegisterShape(Me) End Sub End Class End Namespace Dim P = Shapes.Point(3, 5) print P
Here P is script-level variable, ShapeCount, ShapeList are namespace-level variables, X, Y, X1, Y1, X2, Y2 are class-level non-shared variables (field members), S is procedure-level variable. To distinguish non-shared class members and procedure-level variables, the MyBase keyword is used. (Check for X, Y usage in the Point.New procedure as an example).