Previous Topic: StringificationNext Topic: Reading Data from the Keyboard (stdin)


Writing Data to the Console (stdout)

Scripts often display results or diagnostic messages. Use "?" and "??" commands to write any type of output to stdout, which specifies the console screen when no redirection is specified. To write output from within an expression to stdout, use the qout() and qqout() functions. The function qout() is equivalent to "?" and qqout() to "??". Both commands and functions accept lists of arguments.

?, qout

Writes the string representation of each argument in a list to stdout. A single space is automatically placed between each displayed argument. The output is terminated with a linefeed character.

??, qqout

Writes the string representation of each argument in a list to stdout. A single space is automatically placed between each displayed argument.

Note: The "?" and "??" output commands can only be used at the beginning of a line.

Examples

The "?" command prints the specified value followed by a line feed:

? "Hello World"
Hello World

The "?" command also accepts a comma-separated list of arguments. The displayed arguments are separated with a single space in the output:

? "Hello", "World"
Hello World

The "??" command works like "?", but does not add the line feed at the end of the output. Several "??" commands can be used in a script to construct a single-line output:

?? "Hello"
?? " "
?? "World"

Both commands accept any data type and combinations thereof:

? "Today is", new Date
? "The square root of 2 is", Math.sqrt(2)

Display the numbers from 1 to 10:

for(i=1;i<11;i++)qout(i);