FutureBasic Logo

<<    Index    >> FutureBasic

print   statement



Syntax
print [%(x,y) | !(col,row)] [ { printItem [ {,|;} printItem ...] ]
printf [%(x,y) | !(col,row)] [ formatString [, arg ...] ]

Requires
macOS 10.11+

Description
Use the print statement to print text in the current window (see window output). The text is drawn using the window's current text attributes.

Print Parameters
Parameter
Description
%(x,y) When this optional parameter is used, the first printed character is positioned with its top-left corner at point x,y. If you don't specify this parameter, text appears at the window's current draw position.
!(col,row) When this optional parameter is used, the draw position (x,y) is determined by the current font/size as follows:
  x = width of '0' (zero) character * col
  y = lineHeight * row
If you don't specify this parameter, text appears at the window's current draw position.
printItem A CFString, pascal string, container, integer, float value is drawn in the window at its current draw position.
,
;
A comma or semicolon is used to separate print items. A comma inserts a tab character. A semicolon does not cause any space to be inserted between consecutive print items. Normally, print moves the draw position down to the next line after the last item has been printed. However, if you put a comma or a semicolon at the end of the print statement, the draw position is set to the right of the last item, and is not moved down to the next line. This allows you to continue printing on the same line with a subsequent print statement.
 
print examples
print @"string"

print @"alpha",@"bravo",@"charlie"

CFStringRef s1, s2, s3, s4
s1 = @"A"
s2 = @"B"
s3 = @"C"
s4 = @"D"
print s1;s2;s3;s4

print %(60,85)@"Text starts at 60x, 85y"

print !(22,11)@"Text starts at column 22, row 11"

print 23 * 3 + 2

Printf Parameters
Parameter
Description
%(x,y) When this optional parameter is used, the first printed character is positioned with its top-left corner at point x,y. If you don't specify this parameter, text appears at the window's current draw position.
!(col,row) When this optional parameter is used, the new draw position (x,y) is determined by the current font and size as follows:
  x = width of '0' (zero) character * col
  y = lineHeight * row
If you don't specify this parameter, text appears at the window's current draw position.
formatString A CFString containing a formatter string. Same type of formatter as used with fn StringWithFormat.
arg A comma delimited list of arguments corresponding to the formatString
 
printf example
CFStringRef s = @"String"
long intVal = 45
double dblVal = 2.3456789
printf @"%@ %ld %f", s, intVal, dblVal

Escape characters (CFString only)
Character
Description
\b When a literal string ends with this character, the draw position is set to the right of the string, and is not moved down to the next line. This is same behavior as the semicolon parameter of the print statement.
\t This inserts a tab character. If a literal string ends with this character, the draw position is set to the right of the string. This is same behavior as the comma parameter of the print statement.
 
 
See also
cls; text; String format specifiers