Home
Name Modified Size InfoDownloads / Week
example 2024-11-21
src 2024-11-21
README.txt 2024-11-21 3.8 kB
LICENSE.txt 2013-07-04 31.9 kB
Totals: 4 Items   35.7 kB 1
Introduction

AMBasic is a small and easy basic interpreter.
This is a alpha version and absolutely non final version. I still have much to do and implement.
It is written in C and C++ (11 version ) and you can use it in your project. Infact I have create a small abstract machine that interfaces the basic, thus you can use the interpreter in your project. I have used Code::Blocks 12.11 for Windows.
Of course it's free under GPL licence.

Feature
AMBAsic has two basic type: numerical and string. The string variables have the char '$' postfix.
AMBasic accept one command for each line.
This basic is not case sensitive and the keywords in this version are :

Command
LET

PRINT <comma>|<number_variable|number_const|string_variable|string_const>
INPUT <string_const><comma><number_variable|string_variable>

IF <logic_expression> THEN <statement> ELSE

FOR <variable_assignment> TO <number_variable|number_const> STEP <number_variable|number_const>
NEXT <number_variable>

WHILE <logic_expression>
WEND

DO
UNTIL <logic_expression>

GOTO <label>
GOSUB <label>
RETURN

RUN
LOAD <string_variable|string_const>
SAVE <string_variable|string_const>
END

GET <number_variable|string_variable>
REM <string_variable>
DIM <number_variable|string_variable>(<number_const>,<number_const>,...)
ON <number_variable|number_const> GOTO | GOSUB <label>{,<label>...,<label>}
LIST
NEW
BEEP
CLS
COLOR <number_variable|number_const>,<number_variable|number_const>
DEFAULTCOLOR
BYE

Math function
SQR(<number_variable|number_const>)
SIN(<number_variable|number_const>)
COS(<number_variable|number_const>)
TAN(<number_variable|number_const>)
ATN(<number_variable|number_const>)
EXP(<number_variable|number_const>)
LOG(<number_variable|number_const>)
ABS(<number_variable|number_const>)
SGN(<number_variable|number_const>)
INT(<number_variable|number_const>)
RND(<number_variable|number_const>)

String function
LEN(<string_variable|string_const>)
VAL(<string_variable|string_const>)
ASC(<string_variable|string_const>)
LEFT$(<string_variable|string_const>,<number_variable|number_const>)
RIGHT$(<string_variable|string_const>,<number_variable|number_const>)
MID$(<string_variable|string_const>,<number_variable|number_const>,<number_variable|number_const>)
STR$(<number_variable|number_const>)
CHR$(<number_variable|number_const>)

File function
EOF(<number_variable|number_const>)

FLDLEN(<string_const>)
	Return the length of the field named <string_const>.
	example:
	lenFld = FLDLEN("record")

Print function
TAB(<number_variable|number_const>)
SPC(<number_variable|number_const>)

File command
OPEN <number_variable|number_const>, <string_variable|string_const>, <string_variable|string_const>, <number_variable|number_const>
CLOSE <number_variable|number_const>

FPRINT <number_variable|number_const>,<string_variable|string_const>
FINPUT <number_variable|number_const>,<string_variable>
FPUTC <number_variable|number_const>,<string_variable|string_const>
FGETC <number_variable|number_const>,<string_variable> 

FIELD <string_const>, <nome_variabile_numerica>||<nome_variabile_stringa> AS <number_const>, ...
FWRITE <number_variable|number_const>,<field_name>
FREAD <number_variable|number_const>,<field_name>
FSEEK <number_variable|number_const>,<number_variable|number_const>

TODO:
The instruction & command CALL, DATA, RESTORE, READ, STOP, CONTINUE
DEFFUNC <number_variable|string_variable>(<number_variable|string_variable>, ...)
DEFPROC <number_variable|string_variable>(<number_variable|string_variable>, ...)


The values of colors are:
0     BLACK,
1     RED,
2     GREEN,
3     YELLOW,
4     BLUE,
5     MAGENTA,
6     CYAN,
7     WHITE,
8     BRIGHT_BLACK,
9     BRIGHT_RED,
10    BRIGHT_GREEN,
11    BRIGHT_YELLOW,
12    BRIGHT_BLUE,
13    BRIGHT_MAGENTA,
14    BRIGHT_CYAN,
15    BRIGHT_WHITE
Source: README.txt, updated 2024-11-21