Skip to main content
Version: 0.1.1

System Modules

RayQuiro 0.1.0 includes a built-in system layer for file manipulation, environment variables, external process execution, time tracking, JSON serialization, OS details, TCP networking, HTTP requests, and PostgreSQL database access. These namespaces are compiled directly into the rqio binary and do not require external .dll files.


📁 rayquiro.fs

The rayquiro.fs module provides synchronous filesystem operations.

import rayquiro.fs as fs;

Functions

fs.exists(path)

  • Arguments: path (string) — Absolute or relative path to check.
  • Returns: booleantrue if the file or folder exists, false otherwise.

fs.mkdir(path)

  • Arguments: path (string) — Directory path to create.
  • Returns: booleantrue on success. Creates intermediate directories automatically.

fs.copy(source, target)

  • Arguments: source (string) — Source file path, target (string) — Destination file path.
  • Returns: booleantrue on success.

fs.copy_tree(source, target)

  • Arguments: source (string) — Source directory path, target (string) — Destination directory path.
  • Returns: booleantrue on success. Copies all contents recursively.

fs.remove(path)

  • Arguments: path (string) — Path to file or directory to remove.
  • Returns: booleantrue on success. Deletes directory trees recursively.

fs.read(path)

  • Arguments: path (string) — Path to the text file.
  • Returns: string — The contents of the file. Throws an error if the file cannot be read.

fs.write(path, content)

  • Arguments: path (string) — Path to the destination file, content (string) — Text content to write.
  • Returns: booleantrue on success. Parent directories are created automatically.

🌐 rayquiro.env

The rayquiro.env module allows reading and modifying process environment variables.

import rayquiro.env as env;

Functions

env.get(name)

  • Arguments: name (string) — The environment variable name.
  • Returns: string — The variable's value, or null (or empty string) if not set.

env.set(name, value)

  • Arguments: name (string) — The variable name, value (string) — The value to set.
  • Returns: booleantrue on success. Modifications only affect the current process and its children.

env.path_add(path)

  • Arguments: path (string) — Folder path to append to the user's permanent PATH environment variable.
  • Returns: booleantrue on success. (Windows-only persistent update).

⚙️ rayquiro.process

The rayquiro.process module handles process launching and execution environments.

import rayquiro.process as process;

Functions

process.run(command)

  • Arguments: command (string) — Shell command line to run.
  • Returns: number — The process exit/return code. Blocks execution until the command finishes.

process.exe_dir()

  • Arguments: None.
  • Returns: string — The absolute path of the directory containing the currently running rqio.exe or project runtime root.

⏱️ rayquiro.time

The rayquiro.time module handles timers, sleep delays, and epoch timestamps.

import rayquiro.time as time;

Functions

time.now_ms()

  • Arguments: None.
  • Returns: number — High-resolution runtime clock value in milliseconds (useful for profiling).

time.unix_ms()

  • Arguments: None.
  • Returns: number — Current Unix timestamp (since January 1, 1970 UTC) in milliseconds.

time.sleep(ms)

  • Arguments: ms (number) — Time to sleep in milliseconds.
  • Returns: null — Blocks the current thread for the specified duration.

📄 rayquiro.json

The rayquiro.json module serializes and deserializes JSON strings.

import rayquiro.json as json;

Functions

json.parse(text)

  • Arguments: text (string) — Valid JSON text.
  • Returns: any — A parsed RayQuiro value (arrays, tables, numbers, strings, booleans, or null).

json.stringify(value)

  • Arguments: value (any) — Any RayQuiro runtime value.
  • Returns: string — A serialized JSON string representing the value.

🗄️ rayquiro.db

The rayquiro.db module provides built-in PostgreSQL database access. It dynamically loads the PostgreSQL client library (libpq) at runtime — no manual driver installation in the script is needed.

import rayquiro.db as db;

Requirements: libpq.dll (Windows) or libpq.so (Linux) must be installed on the machine. Install via PostgreSQL client tools or libpq-dev.

Functions

db.connect(connstring)

  • Arguments: connstring (string) — A PostgreSQL connection string.
  • Returns: number — A connection handle (integer). Returns 0 on failure.
  • Example connstring formats:
    • "host=localhost port=5432 dbname=mydb user=postgres password=secret"
    • "postgresql://postgres:secret@localhost:5432/mydb"

db.query(handle, sql)

  • Arguments: handle (number) — Connection handle from db.connect(), sql (string) — SQL SELECT query.
  • Returns: array — An array of row objects. Each row is a table where keys are column names and values are strings.
  • Returns empty array on error.

db.exec(handle, sql)

  • Arguments: handle (number) — Connection handle, sql (string) — SQL statement (INSERT, UPDATE, DELETE, CREATE, etc.).
  • Returns: number — Count of affected rows. Returns 0 on error.

db.scalar(handle, sql)

  • Arguments: handle (number) — Connection handle, sql (string) — SQL query expected to return a single value.
  • Returns: any — The value of the first column in the first row. Returns null if no rows.

db.close(handle)

  • Arguments: handle (number) — Connection handle to close.
  • Returns: booleantrue if the connection was found and closed.

Example

import rayquiro.db as db;

var conn = db.connect("host=localhost port=5432 dbname=mydb user=postgres password=secret");

if (conn == 0) {
print("Failed to connect.");
} else {
// Create table
db.exec(conn, "CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT, score INT)");

// Insert rows
db.exec(conn, "INSERT INTO users (name, score) VALUES ('Alice', 95)");
db.exec(conn, "INSERT INTO users (name, score) VALUES ('Bob', 82)");

// Query all rows
var rows = db.query(conn, "SELECT * FROM users ORDER BY score DESC");
for (var i = 0; i < len(rows); i = i + 1) {
print(rows[i]["name"], "scored", rows[i]["score"]);
}

// Scalar query
var total = db.scalar(conn, "SELECT COUNT(*) FROM users");
print("Total users:", total);

db.close(conn);
}

💻 rayquiro.os

The rayquiro.os module provides utility information about the operating system, current working directory, and path properties.

import rayquiro.os as os;

Functions

os.name()

  • Arguments: None.
  • Returns: string — The operating system name: "windows", "macos", "linux", or "unknown".

os.arch()

  • Arguments: None.
  • Returns: string — The CPU architecture: "x86_64", "x86", "arm64", "arm", or "unknown".

os.cwd()

  • Arguments: None.
  • Returns: string — Current working directory absolute path.

os.chdir(path)

  • Arguments: path (string) — Directory path.
  • Returns: booleantrue if successful.

os.home()

  • Arguments: None.
  • Returns: string — The current user home directory path.

os.temp()

  • Arguments: None.
  • Returns: string — The system temporary files directory path.

os.sep()

  • Arguments: None.
  • Returns: string — The preferred path directory separator (\ on Windows, / on Linux/macOS).

os.exists(path)

  • Arguments: path (string) — File or folder path.
  • Returns: booleantrue if exists.

os.is_dir(path)

  • Arguments: path (string) — Path to check.
  • Returns: booleantrue if path exists and is a directory.

os.is_file(path)

  • Arguments: path (string) — Path to check.
  • Returns: booleantrue if path exists and is a regular file.

🔌 rayquiro.net

The rayquiro.net module provides low-level TCP socket networking capabilities.

import rayquiro.net as net;

Functions

net.tcp_connect(host, port)

  • Arguments: host (string) — Host name or IP address (e.g. "localhost" or "127.0.0.1"), port (number) — TCP port.
  • Returns: number — Socket handle integer. Returns 0 on failure.

net.tcp_send(handle, text)

  • Arguments: handle (number) — Connection handle, text (string) — Data string to send.
  • Returns: booleantrue on success.

net.tcp_recv(handle, maxBytes)

  • Arguments: handle (number) — Connection handle, maxBytes (number, optional) — Maximum buffer size. Defaults to 65536.
  • Returns: string — Received content string, or empty string "" on connection close or error.

net.tcp_close(handle)

  • Arguments: handle (number) — Socket handle to close.
  • Returns: booleantrue if connection closed successfully.

🌐 rayquiro.http

The rayquiro.http module provides an HTTP client layer for simple network requests.

import rayquiro.http as http;

Functions

http.get(url)

  • Arguments: url (string) — HTTP URL (e.g. "http://rq.raytolfas.cc/info").
  • Returns: table — A response object containing:
    • status (number) — HTTP response code (e.g., 200).
    • body (string) — Response payload text.
  • Note: Returns an empty table {} on connection or host lookup failure.

http.post(url, body)

  • Arguments: url (string) — Target HTTP URL, body (string) — Payload text to send.
  • Returns: table — Response object with status and body.