Microsoft KB Archive/45477

From BetaArchive Wiki

Article ID: 45477

Article Last Modified on 11/21/2006

This article was previously published under Q45477


After you CALL TEXTSIZE to change the output text size, rows of characters that you PRINT on the screen still align on the baseline (pixel row) of the previously printed text size (as shown in Example 3 below). If you subsequently perform a LOCATE statement to change the row position, PRINT rows using that position are misaligned vertically by a few pixels compared to the previously PRINTed text (as shown in Examples 1 and 2).

Thus, to avoid misalignment after CALL TEXTSIZE, you should always invoke LOCATE before each PRINT if you plan to use LOCATE at all. LOCATE recalculates the absolute print position (row and column) in a window using the height and width of the character "0" (zero) in the current text size and font.

This information applies to Microsoft QuickBASIC Version 1.00 for Macintosh, the Microsoft BASIC Interpreter Versions 2.00, 2.10, and 3.00 for Macintosh, and the Microsoft BASIC Compiler Version 1.00 for Macintosh.


Example 1

In the following code sample, "world" is aligned a few pixel rows above "Hello" unless you add the LOCATE 1,1 statement:

' Note: TEXTSIZE 12 starts as the default. Change size as follows:
'LOCATE 1,1   ' Add (uncomment) this line to align "Hello world".
PRINT "Hello";
LOCATE 1,6    ' Recalculates cursor position using TEXTSIZE 9
PRINT "world"

Example 2

TEXTSIZE 20    ' Start at text size 20.
LOCATE 5,1     ' Recalculates printing position using text size 20.
FOR J=1 TO 8   ' Demonstrates 8 different text sizes.
TEXTSIZE 20-J  ' Make the text size smaller.
' "AB" prints on same pixel row as "CD_", despite changed text size:
LOCATE 5   ' Recalculates the printing row using current text size,
NEXT       ' shifting the next "CD_ AB" combination upwards.

Example 3

This example shows that changing the TEXTSIZE does not move the base line for PRINTing, thus allowing different text sizes to neatly align on the same row. A consequence of this feature is a new alignment different than that used by the LOCATE statement (which recalculates absolute row and column coordinates).

   LOCATE 3,1
   FOR J=1 TO 21 STEP 3
   PRINT "X_";   ' All these "X_" characters align on the same line.

Additional query words: BasicCom MQuickB

Keywords: KB45477