Comments Within Your Script
Comments are an important part of any Script, so you should always endeavour to make as many comments as possible to record what you are doing and why you are doing it. It saves lots of time later on when you need to re-visit your Script, and is of invaluable assistance to someone else who may be called upon to update or support your Script.
When the Script is compiled into machine code, the comments are simply not included so they do not affect performance by slowing your Scripts down when the code is processed.
There are three ways to construct comments – as a single stand-alone comment line, a multi-line comment, or as a comment at the end of a line of code.
A comment is always prefixed by two forward slashes //.
Within Statelake, a comment will show as italic turquoise text in the Script Editor and will be ignored by the Script Engine.

Single Line Comments
With a single line comment, the comment takes up the entire line.
Starting with the two forward slashes //, the comment will end at the end of that line only. Where more than one individual comment line may be required, these additional single line comments will all need to have the double forward slash line prefix. Without this double slash, any following text will be considered Script and attempts will be made to process the text as such.
For example, line 3 in the following code is a comment.
procedure
OnMapEvent(
var
Value:variant);
var
Eyes:
Integer
;
// loop while Eyes > 10
begin
Eyes:=
20
;
While
Eyes>
10
do
begin
LogInfo(
'Eyes is equal to '
+IntToStr(Eyes));
Inc(Eyes);
end
;
In the following example, lines 2, 3 and 4 are all individual comment lines and will not be processed as code.
procedure
OnMapEvent(
var
Value:variant);
// Code created 12-September-2022 by Sally
// Code amended 8-Aug-23 - Nigel
// Setting T or F flag
begin
If
DR_ACCS[
'ISACTIVE'
].AsString =
'Y'
then
Value :=
true
else
Value :=
false
;
end
;
End-of-line Comments
Short single line comments can be made at the end of a line of Script code.
Prefix any comment with the double-slashes //, but only the text after the double slashes // will be interpreted as a comment.
In the following screen shot the Value will be set to the 10 - the rest of the line is a comment.
procedure
ScriptEvent(
var
Value:variant);
begin
Value:=
19
// this is a comment about why there are an odd number of buttons!
end
;
Multi-line Comments
Starting with the two forward slashes //, any comment will end at the end of that line only, so if treated as many individual lines, then multiple line comments will all need to have the double forward slash line prefix. Without this double slash, any following lines will be considered script and attempts will be made to process the line.
But there is an easier way!
Rather than having several individual line comments within your script, longer comments can be identified by the use of curly brackets, or braces { }. Any text between the braces will be considered to be a single comment.
You start the comment with an opening brace {, and the comment continues until the closing brace } is encountered.
These opening and closing braces { } can be on different lines, and all text between then will be considered to be the comment.
Curly brace comments can start anywhere on a line, but only the text following the opening brace taken as the beginning of the comment.
Both of the following examples are acceptable multi-line comments.
{This is a multi-line comment example to show how to include
lots of detail comments into your script to ensure that there
is no misunderstanding or misinterpretation at any stage.}
procedure
ScriptEvent(
var
Value:variant);
begin
Value:=
10
{This is another example of a multi-line brace
comment about what is going on with the code. This comment can be as long
and as involved as you need it to be.}
end
;
This type of comment can be extremely useful at the beginning of your Script to explain the purpose of the code or to set the scene.