General RulesSpiderBasic has established rules which never change. These are:
Comments are marked by ;. All text entered after ; is ignored by the compiler.
ExampleIf a = 10 ; This is a comment to indicate something.
KeywordsAll keywords are used for general things inside SpiderBasic, like creating arrays (Dim) or lists (NewList), or controlling the program flow (If : Else : EndIf). They are not followed by the brackets '()', which are typically for SpiderBasic functions.
ExampleIf a = 1 ; If, Else and EndIf are keywords; while 'a = 1' ... ; is a variable used inside an expression. Else ... EndIfKeywords are regularly described in the chapters on the left side of the index page in the reference manual.
FunctionsAll functions must be followed by a ( or else it will not be considered as a function, (even for null parameter functions).
ExampleEventWindow() ; it is a function. EventWindow ; it is a variable.Functions are regularly included in the SpiderBasic "Command libraries", described on the right side of the index page in the reference manual.
ConstantsAll constants are preceded by #. They can only be declared once in the source and always keep their predefined values. (The compiler replaces all constant names with their corresponding values when compiling the executable.)
Example#Hello = 10 ; it is a constant. Hello = 10 ; it is a variable.
LabelsAll labels must be followed by a : (colon). Label names may not contain any operators (+,-,...) as well special characters (ß,ä,ö,ü,...). When defined in a procedure, the label will be only available in this procedure.
ExpressionsAn expression is something which can be evaluated. An expression can mix any variables, constants, or functions, of the same type. When you use numbers in an expression, you can add the Keyword $ sign in front of it to mean a hexadecimal number, or a Keyword % sign to mean a binary number. Without either of those, the number will be treated as decimal. Strings must be enclosed by inverted commas.
Examplea = a + 1 + (12 * 3) a = a + WindowHeight(#Window) + b/2 + #MyConstant If a <> 12 + 2 b + 2 >= c + 3 EndIf a$ = b$ + "this is a string value" + c$ Foo = Foo + $69 / %1001 ; Hexadecimal and binary number usage
Concatenation of commandsAny number of commands can be added to the same line by using the : option.
ExampleIf IsCrazy = 0 : Debug "Not Crazy" : Else : Debug "Crazy" : EndIf
Line continuationIf the line contains a big expression, it can be split on several lines. A split line has to end with one of the following operator: plus (+), comma (,), or (|), And, Or, Xor.
ExampleText$ = "Very very very very long text" + #LF$ + "another long text" + #LF$ + " and the end of the long text" OpenWindow(0, 10, 10, 320, 200, "Image viewer")
Typical words in this manualWords used in this manual:<variable> : a basic variable.
<expression> : an expression as explained above.
<constant> : a numeric constant.
<label> : a program label.
<type> : any type, (standard or structured).
Others- In this guide, all topics are listed in alphabetical order to decrease any search time.
- Return values of commands are always Integer if no other type is specified in the Syntax line of the command description.
- In the SpiderBasic documentation are used the terms "commands" and "functions" as well - this is one and the same, independently of a return-value. If a value is returned by the command or function, you can read in the related command description.