9.6 Miscellaneous Scripting Functions

Table 9-5 provides an overview of various scripting functions:

Table 9-5 Scripting Functions

Function

Description

info( message )

Displays a message dialog box with an informational icon. This is part of the standard browser JavaScript extensions, so it is familiar to those who have already used JavaScript.

alert( message )

Displays a message dialog box with a warning/error icon. This is part of the standard browser JavaScript extensions, so it is familiar to those who have already used JavaScript.

confirm( message )

Displays a message dialog box with a question icon, with Yes/No button choices. This is part of the standard browser JavaScript extensions, so it is familiar to those who have already used JavaScript.

This function returns True if the user clicks the Yes button.

prompt( prompt|prompts, title, multiline|multilines )

Similar to confirm(), this prompts the user for information. The prompt argument is a label for a text field where the user enters information. Optionally, the first argument can be an array of strings, which sets up multiple input values.

The title is optional, and denotes the title of the dialog box to display.

The final variable is also optional, and denotes whether or not the prompt text fields are multiple lines or single line (True/False).

The return value is either the string the user entered, or null/undefined. If there are multiple prompts used, it is an array of strings.

Examples:

var result = prompt( 'Enter some information', 'Formula')
print( 'You entered: ' + result )
var results = prompt( [ 'Enter 1', 'Enter 2' ], 'Formula', [ true, false ] )

fload( scriptName )

Loads a script from the script repository. The script repository is in the formula database/scripts directory. For example:

load( 'util/login' ) // Loads the login utility.
login()

@

Loads a script from the script repository. The script repository is in the formula database/scripts directory. Use it when loading the script is the only command being issued and it is not embedded within a script. For example, when creating a custom menu operation or loading a script when an adapter starts (Script.onStarted in adapter properties). For example:

@/login.fs // Loads the login utility.

writeln/write

Write output to standard output. Similar to the standard JavaScript print function.

in/out/err

Standard input, output, and error streams, exposed as variables.

Args

The arguments to the script, as an array of strings. If the script is a command line script, these are the arguments the user entered for the script. If the script is an operation, and the user was prompted for data, this is the data the user entered.