Output of an expression as graphic text
Text x!, y!, sexp
x!, y!:Single
sexp:svar or sexp
Text x, y, sexp prints expression exp as graphic text at coordinates x, y. The ScaleMode property determines the unit of measure used. The point defined with x, y is aligned with the left corner of the base line of the first character in exp. The color of the text is set using RGBColor, Color, or QBColor. When FontTransparent = True or GraphMode ,TRANSPARENT the background is not overwritten with the the background color (2nd parameter of (RGB)Color and QBColor. Otherwise the background of the text is filled.
OpenW # 1
Dim i%, s$ = "Test Test Test"
For i% = 0 To 10
Text 50, Add(Shl(i%, 4), 16), s$
Next i%
Writes "Test Test Test" in different positions down the screen.
Text is considerably faster than Print.
How the text is aligned can be altered by the SetTextAlign() API as shown by the following example:
OpenW 1
// Default 'Top' text alignment
Text 60, 20, "Hello" : FontSize = 12 : Text 90, 20, "Hello" : FontName = "Courier" : Text 135, 20, "Hello"
Text 60, 40, "Hello"
// Outputting Text to align along the base line
~SetTextAlign(Win_1.hDC, 24)
' 24 = TextOut y-coordinate = baseline; SetTextAlign set to 0 or top by default
' SetTextAlign affects Text as the latter uses the TextOut API
FontName = "MS Shell Dlg" : FontSize = 8
Text 60, 80, "Hello" : FontSize = 12 : Text 90, 80, "Hello" : FontName = "Courier" : Text 135, 80, "Hello"
Text 60, 100, "Hello"
' Note: SetTextAlign also affects Print statements as follows:
Print "Line 1" // is printed above the top of the work area of the window
Print "Line 2"
Print "Line 3"
SetTextAlign() can be used with the following constants
TA_BASELINE = 24 - The reference point will be on the baseline of the text.
TA_BOTTOM = 8 - The reference point will be on the bottom edge of the bounding rectangle of the text.
TA_CENTER = 6 - The reference point will be horizontally centered along the bounding rectangle of the text.
TA_LEFT = 0 - The reference point will be on the left edge of the bounding rectangle of the text.
TA_NOUPDATECP = 0 - Do not set the current point to the reference point.
TA_RIGHT = 2 - The reference point will be on the right edge of the bounding rectangle of the text.
TA_RTLREADING = 256 - Win 95/98 only:Display the text right-to-left (if the font is designed for right-to-left reading).
TA_TOP = 0 - The reference point will be on the top edge of the bounding rectangle of the text.
TA_UPDATECP = 1 - Set the current point to the reference point.
Print, Print At, TextXor, GrayText, ScaleMode, Color, RGBColor, QBColor
{Created by Sjouke Hamstra; Last updated: 14/01/2015 by James Gaite}