Skip to content

The IO Standard Library

C272 edited this page Aug 25, 2019 · 4 revisions

This library spans common input and output functions including file reading and writing, inputs from various devices (mouse, keyboard) and serial output.


input.get()

Gets input from the default input method, usually the keyboard (unless one isn't connected).

Parameters:

None.

Usage:

let x = input.get(); //type "foo"
print x; //"foo" is printed

input.fromFile(path)

Returns the contents of the given file, using relative or absolute path, based on the .NET Pathing Engine.

Parameters:

Name Description
path The path of the file to read from.

Usage:

let x = input.fromFile("example.txt");
print x; //prints the contents of example.txt

output.toFile(path, content)

Outputs the given string to a file, using relative or absolute path, based on the .NET Pathing Engine. Overwrites any content that was previously in the file.

Parameters:

Name Description
path The path of the file to write to.
content The content to write to the file. Must be a string.

Usage:

let x = "Write me somewhere!";
output.toFile("example.txt", x); //puts "Write me somewhere!" into example.txt.

output.setConsoleColour(colour)

Sets the output colour for future print statements. The colour is an enum value from the consoleColours enum.

Parameters:

Name Description
colour A consoleColours enum value.

Usage:

output.setConsoleColour(consoleColour.Black); //set the console text colour to black

consoleColour

An enum that represents all colours available to set the console text to. Used in output.setConsoleColour.

Values:

Black,
DarkBlue,
DarkGreen,
DarkCyan,
DarkRed,
DarkMagenta,
DarkYellow,
Gray,
DarkGray,
Blue,
Green,
Cyan,
Red,
Magenta,
Yellow,
White

output.createFile(path)

Creates a file on disk, and writes a blank string to it. Uses relative or absolute path, based on the .NET Pathing Engine. The directories that the file is being created in must all exist, otherwise an error will be thrown.

Parameters:

Name Description
path The path to create a file at.

Usage:

output.createFile("example.txt"); //creates "example.txt" in the executing directory.

file.exists(path)

Checks whether a file exists at the given path. Returns a boolean value.

Parameters:

Name Description
path The file to check the existence of.

Usage:

if (file.exists("example.txt"))
{
    print "./example.txt exists!";
}