System

The System class provides information and access to some features of the runtime environment.

Platform

Detect which platform morpho was compiled for:

print System.platform() 

which returns "macos", "linux", "unix" or "windows".

Version

Find the current version of morpho:

print System.version() 

Clock

Returns the system time in seconds, with at least millisecond granularity. Primarily intended for timing:

var start=System.clock() 
// Do something 
print System.clock()-start 

Note that System.clock measures the actual physical time elapsed, not the time spent in a process.

Sleep

Pauses the program for a specified number of seconds:

System.sleep(0.5) // Sleep for half a second

Readline

Reads a line of input from the console:

var in = System.readline() 

Arguments

Returns a List of arguments passed to the current morpho on the command line.

var args = System.arguments() 
for (e in args) print e 

Run a morpho program with arguments:

morpho5 program.morpho hello world

Note that, in line with UNIX conventions, command line arguments before the program file name are passed to the morpho5 runtime; those after are passed to the morpho program via System.arguments.

Exit

Stop execution of a program:

System.exit()