Please add information to explain each keyword. In the The Small Basic FAQ, it mentions there are 14 keywords in the language:
What are the unique features of the Small Basic language? Size The Small Basic language consists of just 14 keywords.
==========
Here are the 14 Keywords:
Else ElseIf EndFor EndIf EndSub EndWhile For Goto If Step Sub Then To While
And the Operator list2 Operators:
And Or
Within Small Basic a keyword is shown in the intellisense with this keys symbol: ==========
Examples...
If, Then, EndIf
If
(Clock.Hour
Clock
.
Hour
<
12
)
Then TextWindow.WriteLine
TextWindow
WriteLine
(
"Good Morning World")"
EndIf
Else
We can shorten two if..then..endif statements to be just one by using a new word, else.
If we were to rewrite that program using else, this is how it will look:
Then
TextWindow.WriteLine
"Good Morning World") "
ElseTextWindow.WriteLine
"Good Evening World") "
Goto
i
25
start
For, To, EndFor
For..EndFor is, in programming terms, called a loop. It allows you to take a variable, give it an initial and an end value and let the computer increment the variable for you. Every time the computer increments the variable, it runs the statements between For and EndFor.
This program prints out numbers from 1 to 24 in order:
For
=
1
To
24
TextWindow.WriteLine(i
EndFor
Step
But if you wanted the variable to be incremented by 2 instead of 1 (like say, you wanted to print out all the odd numbers between 1 and 24), you can use the loop to do that too.
2
While, EndWhile
The While loop is yet another looping method, that is useful especially when the loop count is not known ahead of time. Whereas a For loop runs for a pre-defined number of times, the While loop runs until a given condition is true. In the example below, we’re halving a number until the result is greater than 1.
number
100
While
>
TextWindow.WriteLine(number
/
EndWhile
Sub, EndSub
A subroutine is a portion of code within a larger program that usually does something very specific, and that can be called from anywhere in the program. Subroutines are identified by a name that follows the Sub keyword and are terminated by the EndSub keyword. Below is a program that includes the subroutine and calls it from various places.
PrintTime( PrintTime()
PrintTime
TextWindow.Write
Write
"Enter your name: ") "
name
= TextWindow.Read(
Read
TextWindow.Write(name
+
", the time now is: ")
PrintTime(")
PrintTime("
Sub
TextWindow.WriteLine(Clock.Time
Time
EndSub
And, ElseIf
percentage >=
75
"The student’s grade is A.")"
ElseIf
percentage
And
60
"The student’s grade is B.")"
35
"The student’s grade is C.")"
Else TextWindow.WriteLine
"The student’s grade is D.")"
Or
Sub subRainyCount
RainyCount
Rainy
"y"
"Y"