Now we need to get to the core of MiniBasic, the "LET" statement. MiniBasic will evaluate arbitrarily complicated arithmetical expressions. The operators allowed are the familiar "+" "-" "*" and "/", and also MOD (modulus). Use parentheses "(" ")" to disambiguate the order of evaluation.
10 PRINT "Enter temperature in Fahrenheit"
20 INPUT f
30 LET c = (f - 32) / 1.8
40 PRINT "=", c, "Celsius"
As well as these, there are a large number of mathematical functions built into MiniBasic, for example POW(x,y), which does exponentiation, SQRT(x) (square root), SIN(x), COS(x) and TAN(x), sine, cosine and tangent. All the trigonometric functions take or return radians. The logarithm function, LN(x), takes a natural logarithm.
There are also two mathematical constants, PI and e (Euler's number). Be careful not to use these as variable names.
To convert radians to degrees, divide by 2 * PI and multiply by 360. To convert a natural, base e log to log10, divide by LN(10).
LET also works on string variables. String variables always end with the character "$", as do string functions.
10 PRINT "What is your name?"
20 INPUT name$
30 LET name$ = "SIR" + " " + name$
40 PRINT "Arise,", name$
Note that expressions such as
LET x = x + 1
are legal and are in fact very useful.
Variable names must be shorter than 31 characters, and mustn't duplicate any MiniBasic keywords.