{{stub}}{{language|FTCBASIC}}<br>
[http://www.lucidapogee.com/index.php?page=ftcbasic FTCBASIC homepage]<br>
<br>
FTCBASIC<br>
<br>
Alpha Version<br>
<br>
by Gemino Smothers 2022<br>
<br>
About:<br>
<br>
FTCBASIC means fast tiny compiled BASIC.<br>
It is a BASIC compiler for x86 DOS.<br>
The compiler is written in QuickBasic and generates FASM output.<br>
Using batch files, you may compile your source to com files instantly.<br>
<br>
Generated com files are tiny and fast.<br>
They start at less than 50 bytes.<br>
<br>
The compiler and language is derived from the Pebble language.<br>
Many of the great features of Pebble have been kept in translation.<br>
As a result, there's support for inline asm, include files, and more.<br>
There's even some basic 1D array and string data type support.<br>
<br>
In all, there's integer, integer array, and string data types.<br>
Floating point is not supported, but may be implemented with libraries.<br>
<br>
IDE:<br>
<br>
A simple WYSWYG IDE for small projects has been included.<br>
It only displays 80 chars each of 200 lines, but has a few advantages.<br>
You may load a file and select the compile option to generate a batch file.<br>
This works even if the file is too large to display.<br>
<br>
Without the IDE, you must manually create the compilation batch files.<br>
The compiler may also be ran by itself to manually type the source file name.<br>
There's plenty of customizable editors you might want to set up as well.<br>
<br>
Language:<br>
<br>
Only unsigned integers may be used in expressions.<br>
Operator precedence is *, /, +, -, <, >, <=, >=, =, <>, AND, and OR.<br>
Parenthesis override operator precedence.<br>
Use \ at the end of your echo to omit the new line.<br>
<br>
Strings:<br>
<br>
String variables must have a $ at the end.<br>
String variables look like name$.<br>
<br>
Arrays:<br>
<br>
Only numbers may be used as the array size. No variables.<br>
Arrays may be used in expressions, with input, and with print.<br>
Array values must be passed to regular variables for other uses.<br>
Likewise for other uses, data must be passed to the array.<br>
Access arrays with @list[index].<br>
Variables and numbers may be used as the index.<br>
Expressions may not be used as the index.<br>
Arrays are indexed with a starting position of 0.<br>
The range is 0 to the specified index - 1.<br><br>
<br>
Keywords:<br>
<br>
REM<br>
(comments)<br>
<br>
DEFINE variable=expression,variable=expression,variable=expression,etc...<br>
DEFINE strvar$="string",strvar$="string",strvar$="string"<br>
DEFINE variable=expression,strvar$="string"<br>
(string variabes must have a $ after the name)<br>
(you may define integers and strings on the same line)<br>
(variables may only be defined once)<br>
<br>
DIM variable[literal number or comma separated list]<br>
(does not support variables as a parameter)<br>
(arrays must be referenced as @list[index])<br>
(array index may be a literal number or variable)<br>
(array index may not be an expression)<br>
<br>
IF expression THEN labelname<br>
<br>
IF expression THEN<br>
ENDIF<br>
<br>
DO<br>
LOOP expression<br>
(loops while condition is true)<br>
(loop with no parameter for an infinite loop)<br>
<br>
LET variable=expression<br>
<br>
CARRY variable<br>
(places remainder of last division operation in a variable)<br>
<br>
0 variable<br>
(same as let variable=0)<br>
(output asm is the same)<br>
<br>
+1 variable<br>
(same as let variable=variable+1)<br>
(produces smaller asm code)<br>
<br>
-1 variable<br>
(same as let variable=variable-1)<br>
(produces smaller asm code)<br>
<br>
PRINT expression OR "TEXT" or string$<br>
(does not support concatenation)<br>
(use \ at the end of the statement to omit the newline)<br>
(string variables already print with the newline omitted)<br>
<br>
INPUT variable<br>
<br>
GOTO labelname<br>
LABEL labelname<br>
<br>
GOSUB subname<br>
SUB subname<br>
RETURN<br>
<br>
SCANKEY variable<br>
(returns the ascii value of any key being pressed)<br>
<br>
ONKEY labelname<br>
(jumps to a label when any key is pressed)<br>
<br>
CURSOR x,y<br>
(moves the text output position)<br>
(variables or numbers may be used as parameters)<br>
<br>
CHR ascii<br>
(echo the character of any ascii value)<br>
(variables or numbers may be used as parameters)<br>
<br>
CLS<br>
(clears the screen)<br>
(supports bios color control options)<br>
(this is demonstrated in the example ballandp.bas)<br>
(further documentation will be included in the beta release)<br>
<br>
PAUSE<br>
<br>
BELL<br>
(rings the PC speaker bell by echoing ascii character 7)<br>
<br>
END<br>
(this command is required to prevent execution past the end of the source)<br>
(it may only be omitted when the program ends with an endless loop)<br>
<br>
COPY string1$,string2$<br>
(copies the contents of string2$ to string1$)<br>
<br>
CONCAT string1$,string2$<br>
(concatenates the contents of string1$ and string2$)<br>
(the result is placed in string1$)<br>
<br>
COMPARE returnvalue,string1$,string2$<br>
(compares the contents of string1$ with string2$)<br>
(if they are exactly the same, the return value is 1 and 0 otherwise)<br>
<br>
LENGTH returnvalue,string$<br>
(returns the length of string$)<br>
<br>
FIND returnvalue,string$,'x'<br>
(returns the first occurance in string$ of 'x' or any other character)<br>
(characters may be represented in single quotes or as literal ascii numbers)<br>
<br>
TRIM string$<br>
(removes spaces from the left and right sides of string$)<br>
<br>
CUT start,amount,string1$,string2$<br>
(parses from start up to the amount and places the result in string1$)<br>
<br>
INTSTR string$,value<br>
(converts a value to a string)<br>
<br>
STRINT value,string$<br>
(converts a string to a value)<br>
<br>
UPPER string$<br>
(converts a string to all upper case)<br>
<br>
LOWER string$<br>
(converts a string to all lower case)<br>
<br>
USE filename.inc<br>
(includes a file at the bottom of the code)<br>
<br>
INCLUDE filename.inc<br>
(includes a file in the code)<br>
<br>
BEGINASM<br>
(start inline asm block)<br>
<br>
ENDASM<br>
(end inline asm block)<br>
<br>
Commands that don't support arrays yet:<br>
<br>
You must use variables to pass values.<br>
<br>
carry, 0, +1, -1, cursor, chr, scankey, cls,<br>
compare, length, find, cut, intstr, strint