Scripting:Syntax
From STNE Wiki
(Difference between revisions)
(→Variable declaration) |
|||
Line 14: | Line 14: | ||
Var WelcomeMessage As String = "Hello galaxy!"; // Declares a string and assigns it a value | Var WelcomeMessage As String = "Hello galaxy!"; // Declares a string and assigns it a value | ||
Var DataTable As CTable = New CTable(); // Declares a variable and assigns a newly created CTable to it | Var DataTable As CTable = New CTable(); // Declares a variable and assigns a newly created CTable to it | ||
- | Var | + | Var InfoTable As New CTable(); // Also declares a variable and assigns a newly created CTable to it, but with less code |
- | + | ||
- | + | ||
== Conditional statements == | == Conditional statements == |
Revision as of 01:12, 15 August 2010
This page describes the syntax of the STNE scripting engine.
As with C style languages, a statement is always terminated by a semicolon. A statement can be a function call, variable declaration or assignment.
Variable declaration
Variables are declared with the code 'Var [VarName] As VarType'. This is best illustrated with a small example:
Var WelcomeMessage As String; // Declares a variable named 'WelcomeMessage' of type String Var DataTable As CTable; // Declares a variable named 'DataTable' of type CTable /* It is also possible to immediately assign a value when declaring variables */ Var WelcomeMessage As String = "Hello galaxy!"; // Declares a string and assigns it a value Var DataTable As CTable = New CTable(); // Declares a variable and assigns a newly created CTable to it Var InfoTable As New CTable(); // Also declares a variable and assigns a newly created CTable to it, but with less code
Conditional statements
It is possible to wrap code in conditional code blocks by using If, Else and ElseIf statements. If and ElseIf statements are followed by a boolean expression between round brackets. Code blocks following the If/Else/ElseIf statements have to be wrapped in curly brackets.
An example:
If (x <= 5) { WriteLine("Five or less."); } ElseIf (x <= 10) { WriteLine("More than five."); WriteLine("Ten or less."); } Else { WriteLine("More than ten."); }