LitDev and Nonki have been helping us build a strong library of Small Basic content on TechNet Wiki.
Please check out this article from litdev:
This article describes the main language elements or ‘grammar’ used by the Small Basic language and gives some suggestions for further study. There are several ‘getting started’ guides, this is just another with a slightly different emphasis.
The Small Basic language has some main grammar features that this article focuses on:
- Keywords – these control the logic of the program such as loop (repeat something For or While) or conditional (branch where the program goes depending on the value of a variable – If), define a subroutine (Sub) etc – they are colored blue in Small Basic.
- Variables (black) – these are names given to things we use and store and do things with – think of them like draws that we can put things in and store these things while we do stuff with them.
- Literals (orange) – Values that are not stored in variables, like a number 3.14 or set of characters in quotes “Hi There!”.
- Objects (gray) – these are special functions that have been provided to do certain things, like add a picture to a display. There are several of them in Small Basic, like TextWindow, Clock etc.
- Methods, Parameters and Events (dark red) – these are found for the different objects by typing a dot after the object. They do the special things – they may also need some data to work with (called parameters) or return some data.
- Comments (green) – anything after a ‘ (single quote) is not read by the compiler it is just comments for you to remember what you did or why – make good use of these.
The first program we usually write in any language is the ‘Hello World’ program that writes this out.
In Small Basic, this is:
TextWindow is an Object
WriteLine is a Method, the brackets show that this method needs some data to work with – in this case, what to write.
“Hello World” is what we want the write and it is put in double quotes – and is called a literal since it is not a variable, but is just a value (not in a draw).
For more info, see the Statements sections in the article…
Once again, thanks to litdev for this great article!
– Ninja Ed