- BOS-BASIC 2
- 04 Sep 2019 01:34:13 pm
- Last edited by beckadamtheinventor on 16 Nov 2019 01:32:25 am; edited 8 times in total
sorry for the long post
I have been working tirelessly on an entirely new BOS-BASIC interpreter.
The syntax of the language has drastically changed.
Hopefully it doesn't change again...
Initially, this was a simple terminal interface with some small commands.
I then realised that it could be much more.
It still functions in-console, but now it can run programs as well.
Also: the [ON] key will stop a program.
Bugfix update!
Download: BOS-BASIC v2.4
Values:
0-9: base 10 number
ex: 10
0x or $: base 16 number
ex: 0x0, $3F
"string of text"
//Bytes array
{48656c6c6f20576f726c64212057454c434f4d4520544f2048454c4c2e20424f53732d48656c6c2c20746861742069732e}
commands:
//Comment
PRINT [value]: print a number to the terminal, return result in Ans
ex: PRINT(100
ex: PRINT("Hello
PUTS [value]: print a string to the terminal, does not return a value
ex: PUTS(Var
ex PUTS("Hello
CLS: clear the terminal
PAUSE: pause execution until a key is pressed
PASS: Do nothing.
getKey: get a keypress, store into Ans. same as ICE/Asm keycodes.
WaitKey: Wait until a keypress, store into Ans.
Input [Value]: Input Value characters from user input. Return string in Ans. Return void if no input or canceled.
NInput [Value]: Input Value characters from user input. Return numerical representation of string in Ans. Return void if no input or canceled.
VInput [Value]: Input Value characters from user input. Return value of the variable named from the string. Return void if no input or canceled.
DOECHO: commands will display in the terminal as they are executed
NOECHO: commands are not displayed during execution. Only gfx and print commands will display.
BBAS [program]: Run a BOS-BASIC program
EXEC [program]: Execute a BASIC program or an Asm program
BBSAVE: Save the terminal and variables.
BBLOAD: Load the terminal and variables from a previous save.
QUIT: Exit the interpreter immediately.
EDIT (Math):
mathematical, comparison, and bitwise operators:
Standard: Add, subtract, multiply, divide, parenthisis.
There is currently no order of operations. The arithmetic goes sequentially.
"+" Add
"-" Subtract
"*" Multiply
"/" Divide
"[value]()" multiply by the value in brackets
"[math]()" do math with the value in brackets
">" Greater than
"<" Less than
">=" Greater than or equal to
"<=" Less than or equal to
"=" Equal to
"!=" Not equal to
"!a" and
"!o" or
"!x" xor
"!+" bitwise and
"!-" bitwise or
"!*" bitwise xor
"!m" modulus (remainder)
If condition: If True, do stuff until the next end
Lbl Label: we can go here later
Goto Label: jump to a label
Call Label: jump to a label, and return on the next line
Return: return to caller.
Test([value]: If value is true, execute next line, else skip it.
ZFILL(numchars,"string",value: Convert value into a string containing at least numchars characters. Fills with "string". Return string.
IO functions:
IO.CLOSEALL
IO.OPEN(varname,mode,vartype->slot
IO.CLOSE(slot
IO.READ(data,len,slot
IO.WRITE(data,len,slot
IO.DELETE(varname,vartype
IO.RENAME(varname_in,varname_out,vartype
IO.GETC(slot->Char
IO.PUTC(char,slot
IO.PUTS(string,slot
IO.SEEK(amount,start,slot: If start==0, seek from beginning of file. If start==1, seek from the current position. If start==2, seek from the end of the file.
IO.PTR(slot: Get a pointer to a file's data at the current offset
IO.LEN(slot: Get the length of a file.
OS functions:
OS.RAND: store a random number into Ans
OS.WAIT(milliseconds: Pause execution for milliseconds.
GFX functions:
GFX.INIT: Set full-graphics mode
GFX.RETURN: Return to console mode
GFX.FLIP: Update the screen
GFX.Sprite(SpritePtr,Xpos,Ypos,{Xscl,Yscl,Mode}: Put a sprite to the screen at (Xpos, Ypos), with scale (Xscl,YScl). If bit 0 of Mode is set, put a transparent sprite.
ex: GFX.Sprite({0202C0E0E0C0},0,0,{404000}
Note on IO functions: they will do nothing if they are passed a string of pointer 0, or a string starting with 0.
Also, Ans is usually set to the return value of the function.
In any expression that returns a value, you may append a "->" followed by a variable. This will store Ans into that variable. This can be done any number of times.
There are two classes of type for each value type. The value, or a pointer to the value. (Kinda like C)
value types:
Void
Int
Bool
Char
Byte
Short
pointer types
Ptr: Pointer to Void. Any kind of data.
Str: Pointer to Char
FS: File slot
type functions:
TYPE.CAST.PTR(value: Get the adress of value.
TYPE.CAST.INT(value: Get the int stored at value.
TYPE.CAST.BYTE(value: Get the byte stored at value.
TYPE.CAST.SHORT(value: Get the short (2 bytes) stored at value.
TYPE.INVERT(value: Get the bitwise xor of value.
TYPE.ABS(vaue: Get the absolute value of value.
TYPE.VOID: Return the type number for void.
TYPE.INT: Return the type number for int.
TYPE.BOOL: Return the type number for bool.
TYPE.CHAR: Return the type number for char.
TYPE.BYTE: Return the type number for byte.
TYPE.SHORT: Return the type number for short.
TYPE.STR: Return the type number for str.
TYPE.PTR: Return the type number for ptr.
Quick examples of BOS-BASIC:
Code:
Code:
What do you guys think?
I have been working tirelessly on an entirely new BOS-BASIC interpreter.
The syntax of the language has drastically changed.
Hopefully it doesn't change again...
Initially, this was a simple terminal interface with some small commands.
I then realised that it could be much more.
It still functions in-console, but now it can run programs as well.
Also: the [ON] key will stop a program.
Bugfix update!
Download: BOS-BASIC v2.4
Values:
0-9: base 10 number
ex: 10
0x or $: base 16 number
ex: 0x0, $3F
"string of text"
//Bytes array
{48656c6c6f20576f726c64212057454c434f4d4520544f2048454c4c2e20424f53732d48656c6c2c20746861742069732e}
commands:
//Comment
PRINT [value]: print a number to the terminal, return result in Ans
ex: PRINT(100
ex: PRINT("Hello
PUTS [value]: print a string to the terminal, does not return a value
ex: PUTS(Var
ex PUTS("Hello
CLS: clear the terminal
PAUSE: pause execution until a key is pressed
PASS: Do nothing.
getKey: get a keypress, store into Ans. same as ICE/Asm keycodes.
WaitKey: Wait until a keypress, store into Ans.
Input [Value]: Input Value characters from user input. Return string in Ans. Return void if no input or canceled.
NInput [Value]: Input Value characters from user input. Return numerical representation of string in Ans. Return void if no input or canceled.
VInput [Value]: Input Value characters from user input. Return value of the variable named from the string. Return void if no input or canceled.
DOECHO: commands will display in the terminal as they are executed
NOECHO: commands are not displayed during execution. Only gfx and print commands will display.
BBAS [program]: Run a BOS-BASIC program
EXEC [program]: Execute a BASIC program or an Asm program
BBSAVE: Save the terminal and variables.
BBLOAD: Load the terminal and variables from a previous save.
QUIT: Exit the interpreter immediately.
EDIT (Math):
mathematical, comparison, and bitwise operators:
Standard: Add, subtract, multiply, divide, parenthisis.
There is currently no order of operations. The arithmetic goes sequentially.
"+" Add
"-" Subtract
"*" Multiply
"/" Divide
"[value]()" multiply by the value in brackets
"[math]()" do math with the value in brackets
">" Greater than
"<" Less than
">=" Greater than or equal to
"<=" Less than or equal to
"=" Equal to
"!=" Not equal to
"!a" and
"!o" or
"!x" xor
"!+" bitwise and
"!-" bitwise or
"!*" bitwise xor
"!m" modulus (remainder)
If condition: If True, do stuff until the next end
Lbl Label: we can go here later
Goto Label: jump to a label
Call Label: jump to a label, and return on the next line
Return: return to caller.
Test([value]: If value is true, execute next line, else skip it.
ZFILL(numchars,"string",value: Convert value into a string containing at least numchars characters. Fills with "string". Return string.
IO functions:
IO.CLOSEALL
IO.OPEN(varname,mode,vartype->slot
IO.CLOSE(slot
IO.READ(data,len,slot
IO.WRITE(data,len,slot
IO.DELETE(varname,vartype
IO.RENAME(varname_in,varname_out,vartype
IO.GETC(slot->Char
IO.PUTC(char,slot
IO.PUTS(string,slot
IO.SEEK(amount,start,slot: If start==0, seek from beginning of file. If start==1, seek from the current position. If start==2, seek from the end of the file.
IO.PTR(slot: Get a pointer to a file's data at the current offset
IO.LEN(slot: Get the length of a file.
OS functions:
OS.RAND: store a random number into Ans
OS.WAIT(milliseconds: Pause execution for milliseconds.
GFX functions:
GFX.INIT: Set full-graphics mode
GFX.RETURN: Return to console mode
GFX.FLIP: Update the screen
GFX.Sprite(SpritePtr,Xpos,Ypos,{Xscl,Yscl,Mode}: Put a sprite to the screen at (Xpos, Ypos), with scale (Xscl,YScl). If bit 0 of Mode is set, put a transparent sprite.
ex: GFX.Sprite({0202C0E0E0C0},0,0,{404000}
Note on IO functions: they will do nothing if they are passed a string of pointer 0, or a string starting with 0.
Also, Ans is usually set to the return value of the function.
In any expression that returns a value, you may append a "->" followed by a variable. This will store Ans into that variable. This can be done any number of times.
There are two classes of type for each value type. The value, or a pointer to the value. (Kinda like C)
value types:
Void
Int
Bool
Char
Byte
Short
pointer types
Ptr: Pointer to Void. Any kind of data.
Str: Pointer to Char
FS: File slot
type functions:
TYPE.CAST.PTR(value: Get the adress of value.
TYPE.CAST.INT(value: Get the int stored at value.
TYPE.CAST.BYTE(value: Get the byte stored at value.
TYPE.CAST.SHORT(value: Get the short (2 bytes) stored at value.
TYPE.INVERT(value: Get the bitwise xor of value.
TYPE.ABS(vaue: Get the absolute value of value.
TYPE.VOID: Return the type number for void.
TYPE.INT: Return the type number for int.
TYPE.BOOL: Return the type number for bool.
TYPE.CHAR: Return the type number for char.
TYPE.BYTE: Return the type number for byte.
TYPE.SHORT: Return the type number for short.
TYPE.STR: Return the type number for str.
TYPE.PTR: Return the type number for ptr.
Quick examples of BOS-BASIC:
Code:
PUTS("Hello World!
PUTS("How are you today?
PUTS("What is your name?
//Input up to 32 characters and store into Name
Input 32->Name
PUTS("Welcome,
PUTS(Name
PUTS(":)
Code:
//This code will write ["txt",0,0,"Hello World!",0] to the appvar "hello"
"hello->Fname
IO.OPEN(Fname,"w",21->FP
IO.PUTS("txt",FP
IO.PUTC(0,FP
IO.PUTS("Hello World!",FP
IO.CLOSE(FP
What do you guys think?