FutureBasic Logo

<<    Index    >> FutureBasic

print   statement

print [@(col,row) | %(h,v)][printItem [{, | ;}[printItem]...]]
print [@(col,row) | %(h,v)][printItem [{, | ;}[printItem]...]]

Use this statement to put text out to the current window or to the currently route'd device. The text is printed using the window's or printer's current font ID, font size, text style, text mode and foreground color (see the text and color statements). The parameters are interpreted as follows:

When the item to be printed is a point, FutureBasic makes special provisions during the print process.

dim mousePos as Point
call GETMOUSE(mousePos)
print mousePos

The output looks like this (194x,167y)

@(col,row) | %(h,v)
This specifies where the first printed character should appear within the window or the printed page. If you use the @(col,row) variant, then col and row represent the text column and row where the first character should appear; the exact pixel location depends on the current font ID and font size. If you use the %(h,v) variant, then h and v represent horizontal and vertical pixel positions; the first printed character is positioned with its lower-left corner at point (h,v). If you don't specify either variant, printing begins at the window's or printer's current pen position.

This can be any of the following:

a string expressionThe string is printed. If the string includes a carriage-return character (ASCII character 13), the character causes the pen to move down to the beginning of the next line.
a numeric expressionThe decimal value of the number is printed. A space character is always printed after the number; if the number is non-negative, a space character is also printed before the number. FutureBasic formats the number in a reasonable way; if you need the number to appear in a special format, use string functions such as Using, Hex$, Str$, etc.
a Pointer or Handle variableThe variable's value is interpreted as an address, which is then printed as a numeric expression (see above).
Tab(position)Sufficient space characters are printed until the current line contains position -1 characters. (If there are already more than position -1 characters on the line, Tab does nothing.) This is usually done to help line up several lines of text into neat columns. Note that this effect looks best if you're using a monospaced font.
Spc(numSpaces)numSpaces space characters are printed. This has the same effect as printing the string expression Space$(numSpaces).

{, | ;}
You must use a comma or a semicolon to separate each pair of printItems; you can also optionally put a comma or semicolon at the end of the print statement (following the last printItem).
A comma causes space characters to be printed until the total number of characters on the line is a multiple of the current "tab field width." Commas are usually used to help line up several lines of text into neat columns, or just to put some space between consecutive printItems.
A semicolon does not cause any spaces to be inserted between consecutive printItems. Use this when you want printItems to be printed as close together as possible.
Normally, print moves the pen down to the beginning of the next line after the last printItem is printed. However, if you put a comma or a semicolon at the end of the print statement, the pen remains to the right of the last printItem, and is not moved down to the next line. This allows you to continue printing on the same line using a subsequent print statement.
Note that you can use print without any parameters, like this:


This simply causes the pen to move down to the beginning of the next line; it effectively "prints" a carriage-return character. This is useful for putting blank line(s) between other lines of text.

Line wrap, scrolling and page-eject
By default, if the printItems reach the right edge of the window or the printer page, the print statement automatically "wraps the line"; that is, it moves the pen down to the beginning of the next line to continue printing the remaining printItems. However, this behavior can be altered using the width statement; see the width statement for more information.
If you're printing to a window, and the print statement causes the pen to move below the bottom of the window, the window's contents are scrolled up so that the newly printed text will be visible.
If you're printing to the printer, and the print statement causes the pen to move below the bottom of the printer page, the page is ejected and printing continues at the top of the next page.

Text which is displayed using the print statement is not automatically refreshed, unless you're using the "FB Lite" runtime. To display text which is automatically refreshed, consider using Edit Fields (see the edit field statement).

See also
text; color; long color; width; using; space; edit field