- Bytecode
- Configuration
- Comments
// - Conditions
ifelseend - Constants
truefalseHIGHLOWINPUTOUTPUT - Cycles
forwhilenextbreakcontinue - Functions
functionlocalsreturndone - Macros
macro - Numeric variables
@@[] - Operators
+-*/%==!=>>=<<=&&||&|^>><<++--~not - Strings
::[] - System functions
adc readargscharcursordelayfile closefile openfile readfile writepipe closepipe openpipe readpipe writeincludeindexinputio openio readio writememmillisnumbernumericprintrandomrestartserial openserial readserial writesizestopstring - Unary operators
++--
Using the adc keyword along with read, write, open and close it is possible to fully handle the ADC (Analog to Digital Converter).
adc read [number or variable]
It receives a single parameter. Reads an analog pin and returns a value between 0 and 1023.
print adc read A0 // Prints a value between 0 and 1023Using the args keyword it is possible to access to arguments that have been passed to the program.
print args[0] // Prints the first argument passed to the programdelay [number or variable]
It receives a single parameter. Pauses the execution of the program for a given amount of milliseconds.
delay 1000 // Pauses the execution of the program for 1 secondUsing the file keyword along with read, write, open and close it is possible to fully handle files.
file open [string or string literal], [number or variable]
It receives two parameters, the file path and the mode. It returns the pointer to the file.
@f = file open "test.txt", 0 // Opens the test.txt file in reading modefile close [pointer to file]
It receives a single parameter, the pointer to file. It closes the file.
file close @f // Closes test.txt filefile read [pointer to file], [variable or number]
It receives two parameters, the file pointer and the mode; It returns one character.
@c = file read @f, 0 // Reads one character from test.txt using read modeAvailable modes:
0: read (r)1: read binary (rb)2: read write (r+)3: read write binary (rb+)4: write (w)5: write binary (wb)6: write read (w+)7: write read binary (wb+)8: append (a)9: append binary (ab)10: append read write (a+)11: append binary read write (ab+)
file write [pointer to file], [string, string literal, variable or number]
It receives two parameters, the file pointer and the value to be written in the file.
file write @f, "Hello world!" // Writes Hello world! test.txtUsing the pipe keyword along with open, read, write and close it is possible to execute a shell command and stream its I/O.
pipe open [string or string literal], [number or variable]
It receives the command to execute and an optional mode. It returns a handle that can be used with pipe read, pipe write and pipe close.
@pipe = pipe open "curl -s https://httpbin.org/get"pipe read [handle]
It receives a single parameter, the pipe handle, and returns one character from the command output or -1 when the pipe is closed.
@c = pipe read @pipepipe write [handle], [number or variable]
It receives two parameters: the pipe handle and the character code to write to the command's stdin.
pipe write @pipe, 'A'pipe close [handle]
It receives a single parameter, the pipe handle. It closes the pipe and terminates the associated subprocess.
pipe close @pipeWith the include keyword it is possible to add at the end of the program the content of a .biplan file.
include [string literal]
The include statement receives a string literal that must contain the path, file name and extension of the file to be included. In the example below hello_world.biplan that contains the line function hello_world() print "Hello World!" return 0 is included at the end of the program. When executed the program prints "Hello World!" and stops.
include "hello_world.biplan"
hello_world()
stopYou can include files from the current directory or use relative paths:
include "mylib.biplan" // File in current directory
include "../libs/mylib.biplan" // Relative path from current directoryStandard libraries are installed in /usr/local/BIPLAN/. To include a standard library, use the absolute path:
include "/usr/local/BIPLAN/math.biplan"
include "/usr/local/BIPLAN/cordic.biplan"
include "/usr/local/BIPLAN/graphics.biplan"index [variable or string]
Receives a single parameter of type variable or string. Returns the position in the buffer of the parameter received.
@roll = 125
@yaw = 150
print index @roll // Prints 0The user's input source can be configured when the BIPLAN_Interpreter is instantiated
input
Returns the user's input, it blocks the execution until a carriage return is detected and it returns one character from the user's input.
@i = input
if @i >= 0 print char @i end // Prints user's inputinput read
Returns one character from the user's input immediately or -1 if no input is received. The user's input source can be configured when the BIPLAN_Interpreter is instantiated.
@i = input read
if @i >= 0 print char @i end // Prints user's inputUsing the io keyword along with read, write, open and close it is possible to fully handle IO (Input Output) ports.
io read [number or variable]
It receives a single parameter. Reads a digital pin, it returns 0 or 1.
print io read 12 // Prints either 0 or 1io write [number or variable], [number or variable]
It receives two parameters, the pin number and the state (0 or LOW, 1 or HIGH). Sets the state of a digital pin.
io write 12, HIGH // Sets the state of pin 12 to HIGHio open [number or variable], [number or variable]
It receives two parameters, the pin number and the mode (0 or INPUT, 1 or OUTPUT). Sets the mode of a digital pin.
io open 12, OUTPUT // Sets pin 12 mode as outputmem[number or variable]
mem[number or variable] = variable or character constant
Can read or write one byte of memory.
mem[0] = 1
print mem[0] // Prints 1millis
Returns the amount of milliseconds elapsed since the program's execution started.
print millis // Prints time elapsed since start upnumber [string or string literal or argument]
Converts a string, string literal or argument to an integer and returns its value.
:test = "123"
print number :test + 1 // Prints 124numeric [variable or number]
Returns true if the input value is a numeric character, false if it is not a numeric character.
@num = '1'
@chr = 'A'
print numeric @num, " ", numeric @chr // Prints true falseprint [comma separated parameter list]
Receives a comma separated parameter list of type number, variable or string. It prints the parameters received. char can be used within print to convert numbers to characters.
print "Hello world!"To clear the screen, if supported by your physical machine, use the restart keyword as shown below.
print restartTo move the cursor, if supported by your physical machine, use the cursor keyword as shown below.
print cursor 0, 0 // Moves the cursor to x 0, y 0random [variable or number]
It receives a single parameter, the exclusive maximum value. Returns a randomly generated number.
print random 10 // Prints a number between 0 and 9restart
Restarts the execution of the program.
restart // Restarts the programUsing the serial keyword along with read, write, open and close it is possible to fully handle serial communication.
serial write [variable, number, string or string literal]
Receives a single parameter of type number or variable or string. Transmits via serial the parameter's value.
serial write "CIAO" // Transmits CIAO via serialserial read
Returns the value received via serial or -1 if no value is received.
print serial read // Prints what is received via serialserial open [string or string literal], [variable or number]
Initializes the serial port.
serial open "COM1", 9600 // Opens serial COM1 at 9600Bdserial close [string or string literal], [variable or number]
Flushes the serial port.
serial close // Flushes serialsize [variable or number or string or string literal]
Receives a single parameter of type variable or string. Returns the length of the parameter received.
@v = 0
print size @v // Prints 4
:s = "Hello world!"
print size :s // Prints 12stop
Halts the execution of the program.
stop //Stops the program's executionstring [variable or number], [string], [variable or number]
Converts a variable or a number to a string. It receives the number to be converted, the string where to save the conversion and optionally the position where to start writing.
@test = 123
string @test, :str
print :str // Prints 123