Skip to content

IO Module

This module provides basic input/output capabilities to the solus VM so that you can actually see what your program is doing. This also includes some other system info.

io.print

io.print(val: any)

Prints the str representation of any value to the console

Parameters

ParameterTypeDescription
valanyAny value possible in solus

Example

solus
io.print("Hello!");

io.println

io.println(val: any)

Prints the str representation of any value to the console, followed by a newline character and flush

Parameters

ParameterTypeDescription
valanyAny value possible in solus

Example

solus
io.println("Hello, World!");

io.time

io.time() -> f64

Returns the time in seconds since the UNIX epoch

io.fread

io.fread(path: str) -> str|err

Attempts to read a file from the specified path

Parameters

ParameterTypeDescription
pathstrThe relative file path

Example

solus
var f = io.fread("test.cfg");
eval(unwrap(f));

io.fwrite

io.fwrite(path: str, content: str) -> nil|err

Writes the provided string to a file at the specified path

Parameters

ParameterTypeDescription
pathstrThe relative file path

Example

solus
unwrap(io.fwrite("test.cfg", obj.stringify(default, false)));
default

io.input

io.input(prefix: str) -> str

Get input from the user in a command line, printing a prefix before hand

Parameters

ParameterTypeDescription
prefixstrThe prefix to print before the prompt

Example

solus
while !should_exit {
    var i = io.input("> ");
    if i == "!\n"
        i = old_i;
    if i != "\n"
        io.println(str(catch([i]() { eval(i) })));
    old_i = i;
}