morilib Mio BASIC


Back


Fundermental

The morilib Mio BASIC is a line numbered BASIC interpreter.
Programs begin line number, and statement is continued.
The word which reserved as functions and statements are available as a variable.
The valid variable name begins ASCII alphabets and follows ASCII alphabets or dot.
The morilib Mio BASIC has only numeric type.
The numbers are exact numbers and inexact numbers.
Exact numbers are You use pi by describing PI, and you can not use the variable named PI.
The number which can not represents as exact number treated by inexact number.
The inexact number is an IEEE float pointed number.
The value is true if the value is not zero, otherwise The value is false.


Expressions

In the morilib Mio BASIC, the expressions shown as follows.
- High priority -
operatoe association description
(unary)- left to right negate the sign
^ right to left power
* / left to right multipication, division
+ - left to right addition, subtraction
= left to right 1 if both value is equal, otherwise 0
<> left to right 1 if both value is not equal, otherwise 0
< left to right 1 if the left value is less than the right value, otherwise 0
> left to right 1 if the left value is more than the right value, otherwise 0
<= left to right 1 if the left value is less than or equal to the right value, otherwise 0
>= left to right 1 if the left value is more than or equal to the right value, otherwise 0
NOT left to right logical not
AND left to right conjunction
OR left to right logical sum


Statements

LET varname=expr
assigns expression to variable.

PRINT expr|"string" [;expr|"string ... [;]]
prints expression or string to text screen.

IF expr THEN stat1 [ELSE stat2]
executes stat1 if expr is true, otherwise stat2.

IF expr1 THEN
stat1
...
[ELSEIF expr2 THEN
stat2
...]
[ELSE
statn
...]
END IF
executes stat1 if expr1 is true, stat2 if expr2 is true, otherwise statn.
ELSE clause is optional.

GOTO line-number
branch to line-number.

END
indicates the end of program.

FOR varname=expr1 TO expr2 [STEP number] / NEXT varname
assigns expr1 to varname, execute until NEXT appear, and increases variable by number(default 1).
The loop repeats until variable is more than expr2.
FOR and NEXT must be balanced.

INPUT [PROMPT "string" :][varname,...]
inputs a value from text and assigns it to variable.
Prompt can be given by PROMPT clause.


Functions

Those are built-in functions. Functions can use in expression. Function without arguments can call by only function name.
INT(expr)
maximum integer which is not more than expr.

FIX(expr)
truncates fractional part of expr.

SIN(expr) / COS(expr) / TAN(expr) / ATN(expr)
sin, cos, tan, inverted tan of expr.
The result returns exact value if possible.

SQR(expr)
Square root of expr.
The result returns exact value if possible (example: SQR(81)=9).

EXP(expr)
Exponent of expr.
The result is inexact number.

LOG(expr)
Natural logarithm of expr.
The result is inexact number.

LOG10(expr)
Common logarithm of expr.
The result is inexact number.

INEXACT(expr)
converts expr to inexact number.

ISEXACT(expr)
returns true if expr is exact number.