Microsoft KB Archive/45477

= PRINT, LOCATE, then PRINT Misaligned If TEXTSIZE Changed =

Article ID: 45477

Article Last Modified on 11/21/2006



This article was previously published under Q45477



SUMMARY
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 &quot;0&quot; (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, &quot;world&quot; is aligned a few pixel rows above &quot;Hello&quot; unless you add the LOCATE 1,1 statement: ' Note: TEXTSIZE 12 starts as the default. Change size as follows: CALL TEXTSIZE(9) 'LOCATE 1,1  ' Add (uncomment) this line to align &quot;Hello world&quot;. PRINT &quot;Hello&quot;; LOCATE 1,6   ' Recalculates cursor position using TEXTSIZE 9 PRINT &quot;world&quot;

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. PRINT &quot;CD_ &quot; TEXTSIZE 20-J ' Make the text size smaller. ' &quot;AB&quot; prints on same pixel row as &quot;CD_&quot;, despite changed text size: PRINT &quot;AB&quot;; LOCATE 5  ' Recalculates the printing row using current text size, NEXT      ' shifting the next &quot;CD_ AB&quot; combination upwards. INPUT X$

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 TEXTSIZE 30-J PRINT &quot;X_&quot;;  ' All these &quot;X_&quot; characters align on the same line. NEXT

Additional query words: BasicCom MQuickB

Keywords: KB45477

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.