Introduction to Polar Script

Polar Script is a scripting language developed by Blue Polar. It is designed to be a successor of VBScript and is fully backwards compatible with VBScript. Polar Script is a powerful language that has many extensions and new features. It can be compared with Visual Basic for Application (VBA).

Basic Syntax

Polar Script has a simple and easy-to-learn syntax that is similar to VBScript. Here is an example of a basic Polar Script program that prints "Hello, World!" to the console:

MsgBox "Hello, World!"

In Polar Script, comments can be added to the code using the Rem keyword or using a single quote. Here are examples of comments in Polar Script:

Rem This is a comment
Dim lCount 'We use lCount for counting

Variables

Polar Script allows you to create and manipulate variables. Variables can hold different types of data, including strings, numbers, and booleans. Here are some examples of creating a variables in Polar Script. As you can see, Polar Script allows you to use strong typing:

Dim lValue
Dim lCount As Long
Dim lName As String
Dim lStartDate As Date = Date()

Operators

Polar Script supports various types of operators, including arithmetic, comparison, logical, and bitwise operators. Here is an example of using arithmetic operators in Polar Script:

Dim a = 10
Dim b = 5
Dim result = a + b

Control Structures

Polar Script supports various control structures, including loops and conditional statements. Here is an example of a For loop in Polar Script:

Dim i As Long

For i = 1 To 10
   SendDebug i
Next

Polar Script also supports conditional statements such as If and Select Case. Here is an example of using the If statement in Polar Script:

Dim a = 10
Dim b = 5
If a > b Then
   SendDebug "a is greater than b"
End If

Functions and Subroutines

Polar Script supports functions and subroutines. Functions are used to return a value, while subroutines are used to perform a specific action without returning a value. Here is an example of a function in Polar Script. Please notice the new 'Return' keyword that acts like the return in JavaScript or C#:

Function AddNumbers(pNumber1 As Double, pNumber2 As Double) As Double
   Dim lResult As Double = pNumber1 + pNumber2
   
   Return lResult
End Function

SendDebug AddNumbers(10, 5)

Data Types

Polar Script supports the following data types:

Data typeNotesDefault
DoubleFor floating point numbers stored in 8 bytes.
-1.79769313486231E308 to -4.94065645841247E-324 (negative number).
4.94065645841247E-324 to 1.79769313486231E308 (positive number)
0
LongInteger stored in 4 bytes.
-2,147,483,648 to 2,147,483,647
0
LongLongInteger stored in 8 bytes.
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
0
StringUnicode texts with virtually unlimited length.""
BooleanA boolean, either True or False.False
DateA Date/Time#1899-12-30#
ObjectAny object, but not basic types as listed above.Nothing
VariantAny type of variable, either objects, arrays or basic types.Empty
ArrayAn n-dimensional array (n >= 1) with values. Arrays can be either typed or untyped (Array of Variants)Variant(-1)

Next to the above real data types, there is a number of pseudo data types. These are specific empty/uninitialized values for specific situations:

Data typeMeaningDetect
EmptyA variant variable is not yet initialised. Behaves as default value for each type when used as such.IsEmpty(pVariable)
MissingA Variant parameter is omitted and no default value was specified. Behaves as default value for each type when used as such.IsMissing(pVariable)
VoidA ?-expression on a missing object was performed, as in: lValue = lMissingObject?.Value Behaves as default value for each type when used as such.IsVoid(pVariable)
NothingAn empty object. Is also the default for object variables. Please be aware that IsObject(Nothing) returns True.IsNothing(pVariable)
NULLA database-null value. When used in functions or calculations may return error 'Invalid use of NULL'. Treated as an empty string when used in a concatenation.IsNull(pVariable)
IsNotNull(pVariable)