System Functions

In addition to the standard Javascript built-in functions, PinballY provides a number of its own functions for access to system features. These are described below.

Many of these are similar to the like-named functions in a Web browser. We've tried to use the same names and behavior when there's a good conceptual match between the way a browser works and the way PinballY works.

alert(message): Shows a system dialog box with the given message text. This pops up a standard modal Windows message box with an OK button, and pauses the script until the user dismisses the dialog. This can be handy for script debugging, but it should be avoided for anything else, as it doesn't fit very well with PinballY's pin cab interaction style. See message() for a friendlier alternative for alerting the user, and logfile.log() for another option for debug messages.

clearInterval(id): Cancels an interval event created with setInterval(). The id value is the value returned from setInterval() when the event was created. This removes the event and prevents any pending execution from occurring. It's harmless to cancel an interval that doesn't exist or that has already been canceled.

clearTimeout(id): Cancels a pending timeout event created with setTimeout(). The id value is the value returned from setTimeout() when the event was created. This removes the event and prevents any pending execution from occurring. It's harmless to cancel a timeout that doesn't exist or that has already been canceled. This will also have no effect if the timeout has already been executed, since you can't "take back" the previous execution.

createAutomationObject(name): Creates an OLE Automation object of the given class name. Automation objects are scripting language interfaces provided by Windows and by various applications. This is similar to the Visual Basic function CreateObject(). See OLE Automation for more details.

message(message, style): This is an alias for mainWindow.message().

setInterval(function, interval_in_milliseconds): Sets up an interval event, which invokes the given function periodically, at (approximately) the specified interval. Each the time function is invoked, the internal event timer is automatically reset so that the event will be called again after another interval of the same time elapses. The function returns an ID value that can be used to cancel the repeating event via clearInterval(). Like Javascript in a browser, PinballY's Javascript is single-threaded, so an interval event can't "interrupt" an executing script; if the next scheduled event time happens to occur while another script is executing, the interval function will be invoked when the current script finishes.

setTimeout(function, timeout_in_milliseconds): Sets up a timeout event, which invokes the given function once, after the given interval elapses. The function returns an ID value that can be used to cancel the timeout before it executes via clearTimeout(). As with Javascript in a browser, PinballY's Javascript is single-threaded, so timer events can't "interrupt" other scripts. If the timeout period elapses while another script is running, the function will be invoked when the current script finishes.