8-13 Minute Read

The Blue Standard Library Reference

Learn about the tools Blue offers to make your experience better and easier.

ArrayTools

A cross platform way to modify and work with arrays.

Accessed by opening ‘ArrayTools’ in a Blue source code file.

Methods:

  • pop(array) – Returns a new array equivalent to ‘array’ with the exception of ‘array’s last element being removed.
  • shift(array) – Returns a new array equivalent to ‘array’, with the exception of ‘array’s first element being removed.
  • addElement(array, element) – Returns a new array equivalent to ‘array’, with ‘element’ added at the end of it.
  • arraySize(array) – Returns the number of elements in ‘array’.

File

A simple way to read from and write to files.

Accessed by opening ‘File’ in a Blue source code file.

Methods:

  • read(filename) – Returns the content of the file specified in ‘filename’.
  • write(filename, newcontent) – Writes to the file specified in ‘filename’ so that its content matches the string or char specified in ‘newcontent’.

MathTools

A library that simplifies doing complex math and trigonometry.

Accessed by opening ‘MathTools’ in a Blue source code file.

Methods:

  • arccos(y) – Returns the trigonometric arc cosine of the angle specified in ‘y’.
  • arcsine(y) – Returns the trigonometric arc of the angle specified in ‘y’.
  • cosine(y) – Returns the trigonometric cosine of the angle specified in ‘y’.
  • sine(y) – Returns the trigonometric sine of the angle specified in ‘y’.
  • floorValue(y) – Returns the largest value under or equal to ‘y’.

SocketTools

A high level networking API that uses TCP sockets.

Accessed by opening ‘SocketTools’ in a Blue source code file.

Methods:

  • socketMake(tag) – Registers a socket that can be accessed in other SocketTools methods binded to the string specified in ‘tag’.
  • socketConnect(tag, host, port) – Connects the socket binded to ‘tag’ to ‘host’:’port’. If you have not called socketMake(tag), this method will not do anything.
  • socketWrite(tag, data) – Writes ‘data’ to the connected socket. If you have not called socketMake(tag), this method will not do anything.
  • socketRead(tag) – Reads all the data available to the socket binded to ‘tag’. If you have not called socketMake(tag), this method will not do anything. On the cpp target, this will only return up to 1024 bytes of data.
  • socketDestroy(tag) – Removes ‘tag’ from the list of valid socket tags and closes the socket binded to it. If you have not called socketMake(tag), this method will not do anything.

Strings

A library with multiple modern string and char utilities.

Accessed by opening ‘Strings’ in a Blue source code file.

Methods:

  • stringSize(text) – Returns the number of characters in the string specified in ‘text’, this will always return ‘1’ for variables or methods of type ‘char’.
  • stringReplace(text, toReplace, replacement) – Returns a new string with all occurrences of ‘toReplace’ in ‘text’ replaced with ‘replacement’.
  • stringSub(text, firstInt, secondInt) – Returns a new string containing all text from the character location ‘firstInt’ to but not including ‘secondInt’. 

System

A library that simplifies low level functionalities.

Accessed by opening ‘System’ in a Blue source code file.

Methods:

  • sh(command) – Runs the string specified in ‘command’ as a system command.
  • shutdown(exitCode) – Shuts down the program using the exit code specified in ‘exitCode’.
  • varTrace(variable) – Prints the value or variable specified in ‘variable’ to the standard input. This is a great alternative to the ‘print!’ macro in contexts where you need to print a variable and not a whole value.
  • varRead(prompt) – Reads a value from the standard input, printing out the prefix specified in ‘prompt’. The program will continue to run until an input is entered or until it is closed.

Written by: Stephen Byrne