Topic group Related topics Example
Outputs the results or return values of one or more expressions to a new line in the Command window results pane. You can also simultaneously stream output to a print buffer and/or text file.
Syntax
?
[<exp 1>
[PICTURE <format expC>]
[FUNCTION <function expC>]
[AT <column expN>]
[STYLE [<fontstyle expN>] or [<fontstyle expC>]]
[,<exp 2>...]
<exp 1>[,<exp 2> ...]
Expression(s) of any data type. Output consists of expression results or return values.
PICTURE <format expC>
Formats <exp 1>, or a specified portion of it, with the picture template <format expC>, a character expression consisting of one of the following:
Template characters.
Function symbols preceded by @. (You can also use the FUNCTION option, discussed below.)
Literal characters.
A combination of template characters, function symbols, and literal characters.
A variable containing the character expression.
You can use all the template character and function symbols except A, M, R, and S.
FUNCTION <function expC>
Formats all characters in <exp 1> with the function template <function expC>, which must contain one or more function symbols. When you specify function symbols with the FUNCTION option, you don't have to precede them with @.
AT <column expN>
Specifies a character position at which to start the line. The <column expN> argument, effectively a temporary indent, must be between 0 and 255. Note: The AT parameter is ignored if _wrap is true.
STYLE [<font expN>] or [<style expC>]
Specifies a font number or style for printed output only. Does not apply to file or Command window output (files always use the default printer font, typically Courier, and Command window font style is controlled through Command window properties). See description below for print STYLE specification details.
Description
Use ? to output the results or return values of one or more expressions to a new line in the Command window results pane. You can also simultaneously stream output to a print buffer and/or text file.
Output can be streamed to any or all of these targets at the same time, and streaming to a print buffer or file can be switched on or off any time without affecting the stream to other targets.
You can also stream output using the ?? command. The difference is that ?? appends output to the current line and ? always outputs to a new line.
To use either command, type ? or ?? in the input pane of the Command window (or issue it from a program), follow it with your expression(s) and any optional parameters, then press Enter. The results or return values are immediately streamed to the results pane of the Command window as well as to a print buffer and/or file, if either of those streams is turned on.
To erase the contents of the results pane any time, use the CLEAR command in the input pane. Note that this command only clears the results pane of the Command window and does not affect output to a print buffer or file, if either stream is turned on.
To clear all or a portion of the input pane, select the portion you want to clear and press Del.
Streaming output to a text file
To stream output to a file, first specify a target file with the command SET ALTERNATE TO, e.g.,
set alternate to "c:\output.log"
A filename is required (no default is supplied).
Then turn on the file output stream with the command SET ALTERNATE ON.
If you specify a file name without an extension, .TXT is appended to the name. If you don’t specify a path, the current path (as shown in the Navigator "Look In" path selector) is used.
You can pause streaming to a file with the command SET ALTERNATE OFF (and resume it again with SET ALTERNATE ON), but to stop streaming and close the file, you must either use CLOSE ALTERNATE or switch output files by issuing another SET ALTERNATE TO command with a different filename or with no filename parameter.
Only one file at a time can be open for text output streaming, and the contents of that open file cannot be viewed until the file is closed using one of the methods above.
If the file you specify in a SET ALTERNATE TO command already exists, you’re given the option of overwriting the existing file. If you choose No, text the named file is not opened for text streaming. In addition, if another file was already open for output, streaming to that file stops and the file is closed. To reopen the closed file, you must reissue SET ALTERNATE TO with the filename; to resume output (append to the previously closed file at the point output was cut off), use ADDITIVE as described below, then reissue the SET ALTERNATE ON command.
If you do choose Yes and overwrite the existing file, the file is immediately emptied. Text streaming will not start again, however, until you issue the SET ALTERNATE ON command.
To append to an existing file, use ADDITIVE with SET ALTERNATE TO:
set alternate to "c:\output.log" additive
The overwrite warning is not issued when ADDITIVE is used.
Tip
Since ? begins with a line feed to create each new output line, the first line in a new output file or print buffer will be blank. If you want the first line to contain text output instead, use the ?? command for the first item (rather than the ? command).
?? "first item"
? "second item"
Streaming output to a printer
To stream output to a print buffer, use SET PRINTER ON. To print the contents of the print buffer to your current printer, use SET PRINTER TO. To print the buffer to a different printer, specify a port or network printer, e.g.,
set printer to lpt1
or
set printer to \\server9\printer4
The print buffer continues to receive output until you print the contents of the buffer or issue SET PRINTER OFF.
To format printed output in a particular font, size and style, you can either specify a font in "Font,Size,Style" format or use GETFONT( ) to choose a style. Either way, the font definition is applied to the ? command’s STYLE parameter to format the associated line, word or block. This example shows three ways to set the font:
// turn on the print buffer
set printer on
// assign a font definition to the variable headingStyle by using getfont( )
headingStyle = getfont( )
? "Program Log" style headingStyle
// you can also specify a font and apply it without using getfont( )
bodyStyle = "Arial,9,Swiss"
// font formatting for the date( ) item in this block
// is specified directly with the STYLE parameter
? "Date: " style "Arial,9,BI,Swiss", date( ) style bodyStyle
// print the two lines to the default printer
set printer to
You can get definitions for any font on your system by using GETFONT( ) to open a Font dialog, selecting your font options, and examining the result:
s = getfont( )
? s
// selecting 16-pt Arial bold in the Font dialog returns "Arial,16,B,Swiss"
To apply a print style to the default font, you can use codes as shown below in place of a font specification:
//make default text:
? "bold" style "B"
? "italic" style "I"
? "strikeout" style "S"
? "underlined" style "U"
? "superscript" style "R"
? "subscript" style "L"
? "or use any combination, such as bold italic" style "BI"
To overstrike a line of text from a program file in printed output, use the AT option with _wrap set to false. To overwrite rather than overstrike text in printed output, use the AT option with _wrap set to true, which causes only the second line to print.
To override both an overall _alignment setting and individual paragraph alignments in a memo field, use the B, I, or J functions.
Tip
If SET SPACE is ON (startup default; to test, use ? SET("SPACE")), a space is inserted between multiple expressions streamed out to the same line and between expressions appended to the current line with the ?? command. To remove the spaces for literal formatting, use SET SPACE OFF.