Blue Standard Library

Learn Blue’s useful yet compact standard library to make the most of what you are given out of the box.


Libraries

ArrayTools

Basic utilities for manipulating tabs and other elements of the browser.

pop(self: array): array

Returns a copy of array with the last element removed.

shift(self: array): array

Returns a copy of array with the first element removed.

addElement(self: array, element): array

Returns a copy of array with element appended to it.

arraySize(self: array): integer

Returns the number of elements in array.

File

Very basic file IO tools.

read(filename: string): string

Returns the contents of the file path specified in filename.

write(filename: string, contents: string): null

Erases the contents of the file path specified in filename and replaces it with contents.

MathTools

Premade mathematics methods.

arccos(y: float): float

Returns the trigonometric arc cosine of the angle specified in ‘y’.

arcsine(y: string): float

Returns the trigonometric arc of the angle specified in ‘y’.

cosine(y: string): float

Returns the trigonometric cosine of the angle specified in ‘y’.

sine(y float): float

Returns the trigonometric sine of the angle specified in ‘y’.

floorValue(y: string): float

Returns the largest value under or equal to ‘y’.

SocketTools

A high level TCP networking API.

socketMake(tag: string): null

Registers a socket that can be accessed in other SocketTools methods bind to the string specified in tag.

socketConnect(tag: string, host: string, port: string): float

Connects the socket accessed with tag to host : port. If you have not called socketMake(tag), this method will not do anything.

socketWrite(tag: string, data): float

Writes data to the connected socket. If you have not called socketMake(tag), this method will not do anything.

socketRead(tag: string)

Reads all the data available to the socket mapped to tag. If you have not called socketMake(tag), this method will not do anything.

socketDestroy(tag: string): null

Removes tag from the list of valid socket tags and closes the socket mapped to it. If you have not called socketMake(tag), this method will not do anything.

Strings

String utilities.

stringSize(self: string): integer

Returns the size in chars of the string specified in self.

stringReplace(self: string, capture: string, replace: string): string

Returns a new string with all occurrences of capture replaced with replace.

stringSub(self: string, start: integer, end: integer): string

Returns a new string containing all text from the character index start to (but not including) end

System

A high level interface for system-provided functionality.

sh(command: string): null

Runs command as a system command.

shutdown(code: integer): null

Manually exit the program with the exit status specified by code.

echo(message): null

Sends message to the standard output.

printLine(message): null

Equivalent to echo(message + "\n").

readLine(prompt: string): string

Reads a value from the standard input, printing out the prefix specified in prompt. The program will to wait until an input is entered or until it is closed.

Files are Libraries

A “library” in Blue is simply an alias for a source file containing functions that can be called directly or indirectly from the main file where your code starts executing. The terminology used in the language reflects this, as to access a library, you first need to use the “open” keyword – which references opening a file.