This module provides native bindings for console interactions, file operations, and standard stream manipulation.
Prints the value to the standard output without a newline.
Displays a prompt and reads a line of text from standard input.
Displays a prompt and reads an integer from standard input. Throws an error if input is invalid.
Displays a prompt and reads a floating-point number from standard input.
Reads the entire content of the file at the specified path. Returns the content as a string.
Writes the content to the file at the specified path. Overwrites existing content. Returns true on success.
Appends the content to the end of the file at the specified path. Returns true on success.
Reads all remaining content from the Standard Input (stdin). Useful for reading data piped from other programs.
Writes content directly to Standard Output (stdout).
Clears the console screen and moves the cursor to (0,0).
Moves the console cursor to the specified coordinates.
Returns the current cursor position as a struct {x: Int, y: Int}.
var pos = __native_get_cursor();
println("Cursor Position: (" + pos.x + "," + pos.y + ")");class IO {
static func readFile(path: String) -> String {
return __native_file_read(path);
}
static func writeFile(path: String, content: String) {
__native_file_write(path, content);
}
static func appendFile(path: String, content: String) {
__native_file_append(path, content);
}
static func clear() {
__native_clear_console();
}
static func moveCursor(x: Int, y: Int) {
__native_set_cursor(x, y);
}
}
IO.writeFile("log.txt", "Start Log\n");
IO.appendFile("log.txt", "Entry 1: Success\n");
var logs = IO.readFile("log.txt");
println(logs);