The sys namespace provides essential system operations including I/O, time, process control, and foreign function
interface capabilities.
sys::Print(msg: String): Void- Prints a string to standard outputsys::PrintLine(msg: String): Void- Prints a string followed by a newlinesys::ReadLine(): String- Reads a line from standard input, returnsnullon EOFsys::ReadChar(): Char- Reads a single character from standard input, returnsnullon EOF
sys::UnixTime(): Int- Returns current Unix timestamp (seconds since epoch)sys::UnixTimeMs(): Int- Returns current Unix timestamp in millisecondssys::UnixTimeNs(): Int- Returns current Unix timestamp in nanosecondssys::NanoTime(): Int- Returns high-resolution monotonic time in nanoseconds
sys::FormatDateTime(timestamp: Int, format: String): String- Formats Unix timestamp using format stringsys::ParseDateTime(dateString: String, format: String): Int- Parses date string to Unix timestamp
%Y- 4-digit year (e.g., 2024)%m- Month (01-12)%d- Day of month (01-31)%H- Hour (00-23)%M- Minute (00-59)%S- Second (00-59)%s- Unix timestamp
sys::FileExists(path: String): bool- Checks if file existssys::DirectoryExists(path: String): bool- Checks if directory existssys::CreateDirectory(path: String): bool- Creates directory, returnsfalseon errorsys::DeleteFile(path: String): bool- Deletes file, returnsfalseon errorsys::DeleteDirectory(path: String): bool- Deletes empty directory, returnsfalseon errorsys::MoveFile(source: String, destination: String): bool- Moves/renames filesys::CopyFile(source: String, destination: String): bool- Copies file
sys::ListDirectory(path: String): StringArray?- Lists directory contents, returnsnullon errorsys::GetCurrentDirectory(): String?- Returns current working directorysys::ChangeDirectory(path: String): bool- Changes current directory, returnsfalseon errorsys::GetAbsolutePath(path: String): String?- Returns absolute path, ornullon error
sys::Sleep(ms: Int): Void- Sleeps for specified millisecondssys::SleepNs(ns: Int): Void- Sleeps for specified nanosecondssys::Exit(code: Int): Never- Terminates the process with exit codesys::GetProcessId(): Int- Returns current process IDsys::GetEnvironmentVariable(name: String): String?- Gets environment variable valuesys::SetEnvironmentVariable(name: String, value: String): bool- Sets environment variable
sys::Random(): Int- Returns random 64-bit integersys::RandomRange(min: Int, max: Int): Int- Returns random integer in range [min, max)sys::RandomFloat(): Float- Returns random float in range [0.0, 1.0)sys::RandomFloatRange(min: Float, max: Float): Float- Returns random float in range [min, max)sys::SeedRandom(seed: Int): Void- Seeds the random number generator
sys::GetMemoryUsage(): Int- Returns current memory usage in bytessys::GetPeakMemoryUsage(): Int- Returns peak memory usage in bytessys::ForceGarbageCollection(): Void- Forces garbage collectionsys::GetProcessorCount(): Int- Returns number of available CPU cores
sys::GetOsName(): String- Returns operating system namesys::GetOsVersion(): String- Returns operating system versionsys::GetArchitecture(): String- Returns CPU architecture (e.g., "x64", "arm64")sys::GetUserName(): String- Returns current usernamesys::GetHomeDirectory(): String- Returns user's home directory
sys::Interope(dllName: String, functionName: String, input: ByteArray, output: ByteArray): Int- All interop calls are
unsafe. - Returns 0 on success, non-zero error code on failure
inputcontains parameters to pass to the functionoutputbuffer receives the function's return value
- All interop calls are
// Get current time in different formats
val unixTime: Int = sys::UnixTime()
val unixTimeMs: Int = sys::UnixTimeMs()
val unixTimeNs: Int = sys::UnixTimeNs()
// Format current time
val formatted: String? = sys::FormatDateTime(unixTime, "%Y-%m-%d %H:%M:%S")
if (formatted != null) {
sys::PrintLine("Current time: " + formatted)
}
// High-precision timing
val start: Int = sys::NanoTime()
// ... do some work ...
val end: Int = sys::NanoTime()
val duration: Int = end - start
sys::PrintLine("Operation took " + duration.ToString() + " nanoseconds")
val path : String = "TEMP_OVUM_FILE.txt"
val copyPath : String = "COPY_TEMP_OVUM_FILE.txt"
val content : String = "quidquid id est, timeo Danaos et dona ferentes."
val contentBytes : ByteArray = content.ToUtf8Bytes()
contentBytes.RemoveAt(-1) // circular indexing
var file : File = File()
file.Open(path, "w")
file.WriteLine(content)
file.Close()
var readFile : File = File()
readFile.Open(path, "r")
val extractedContent : String = readFile.ReadLine()
readFile.Close()
sys::PrintLine(extractedContent)
sys::CopyFile(path, copyPath)
var copyFile : File = File()
copyFile.Open(path, "r")
var extractedBytes : ByteArray = copyFile.Read(content.Length())
copyFile.Close()
// Get system information
sys::PrintLine("OS: " + sys::GetOsName() + " " + sys::GetOsVersion())
sys::PrintLine("Architecture: " + sys::GetArchitecture())
sys::PrintLine("CPU cores: " + sys::GetProcessorCount().ToString())
sys::PrintLine("Memory usage: " + sys::GetMemoryUsage().ToString() + " bytes")
// Environment variables
val path: String? = sys::GetEnvironmentVariable("PATH")
if (path != null) {
sys::PrintLine("PATH: " + path)
}
Note: All function names use PascalCase (e.g.,
UnixTime,OpenFile). The namespace remainssys.