Developer Resources
System
Overview
The System class provides basic system functionality, such as the sleep() function for waiting, or the clock() function for timing functionality.
Methods
- System.beep
- Creates a system beep.
- System.clock
- Returns the CPU clock value.
- System.execute
- Execute a system command; Run a program
- System.getClocksPerSecond
- Returns number of CPU clock ticks per second.
- System.sleep
- Pauses execution for a specified number of milliseconds
- System.time
- Returns the number of seconds elapsed since January 1, 1970 UTC.
Example
// sleep (pause) for two and a half seconds System.sleep(2500); // now measure the time it takes for the user to press ok var clock1, clock2; clock1 = System.clock(); alert("Press Ok."); clock2 = System.clock(); alert("It took " + (clock2-clock1)/System.getClocksPerSecond() + " seconds to click Ok."); // now launch notepad System.execute("notepad");
System.beep
- static function System.beep(frequency : Integer, duration : Integer)
Arguments
- frequency
- The frequency of the beep in hertz.
- duration
- The duration of the beep in milliseconds.
Description
Creates a system beep. If no parameters are specified, the function creates a default system beep. If parameters are specified, the function creates a beep having the given frequency and duration.
System.clock
- static function System.clock() : Number
Returns
The value of CPU clock.
Description
Returns the CPU clock value. This is useful for measuring how long a piece of code takes to run. It is a basic tool for performance testing. By calling the getClocksPerSecond() function, the user can determine how many seconds have elapsed, to a high degree of accuracy.
System.execute
- static function System.execute(command : String) : Integer
Arguments
- command
- The command line to execute, including the program path and command line parameters.
Returns
The process id of the new process, or zero if the operation failed.
Description
Calling execute runs another program. The program is launched asynchronously, meaning that execution in the calling scope is not blocked, and the program will be run in the background. The command parameter represents the entire command line, including program path and command line parameters.
System.getClocksPerSecond
- static function System.getClocksPerSecond() : Number
Returns
The number of clock ticks per second.
Description
Returns number of CPU clock ticks per second. This is useful in conjunction with the clock() method.
System.sleep
- static function System.sleep(milliseconds : Number)
Arguments
- milliseconds
- The number of milliseconds to sleep.
Description
Pauses execution in a thread-friendly manner for the specified number of milliseconds.
System.time
- static function System.time() : Number
Returns
The number of seconds elapsed since January 1, 1970 UTC.
Description
Returns the number of seconds elapsed since 00:00 hours, January 1, 1970 UTC.