Microsoft KB Archive/58025

= DRAW Statement's Scale (S) Command Has Default Scale Factor 4 =

Article ID: 58025

Article Last Modified on 11/21/2006



This article was previously published under Q58025



SUMMARY
The DRAW statement can scale the lines that it draws. The scale factor is specified by including the &quot;S&quot; command, followed by a number from 1 to 255, before the commands that actually draw the lines.

Certain manuals listed below fail to state that the default DRAW scale factor is 4, and they give the wrong formula to calculate the actual distance drawn.

A scale factor of 8 must follow the &quot;S&quot; command to make a drawing twice as large. A scale factor of 2 makes a drawing half as large (4 * 1/2 = 2).



MORE INFORMATION
The following is the corrected formula for the DRAW &quot;S n&quot; (set Scale factor n) command:

The default scale factor n is 4, which causes no scaling. The scale factor multiplied by movement-command arguments (U, D, L, R, or relative M commands) divided by 4 gives the actual distance moved.

This correction applies to the DRAW &quot;S n&quot; command in the following manuals:


 * 1) Page 138 of the &quot;Microsoft QuickBasic 4.5: Basic Language Reference&quot; manual for Version 4.50

Note: The QB Advisor online Help of QuickBasic 4.50 correctly includes the fact that 4 is the default scale factor.
 * 1) Page 165 of the &quot;Microsoft QuickBasic 4.0: Basic Language Reference&quot; manual for Versions 4.00 and 4.00b
 * 2) Page 165 of the &quot;Microsoft Basic Compiler 6.0: Basic Language Reference&quot; manual for Versions 6.00 and 6.00b
 * 3) Page 255 of the &quot;Microsoft QuickBasic Compiler&quot; Version 2.0x and 3.00 manual

This documentation error was corrected in the &quot;Microsoft Basic 7.0: Language Reference&quot; manual, provided with Microsoft Basic Professional Development System (PDS) Version 7.00 for MS-DOS and MS OS/2.

Knowing that the default scale factor is 4, it is easy to calculate the length of any line given any possible scale factor. The following formula can be used to do this: = ( / 4) * Here is the unscaled distance that is given immediately after the drawing commands.

Code Example
The following program examples illustrate the correct use of the &quot;S&quot; command and how some scale factors affect what will be drawn. This example requires an EGA or VGA card. If you have a different card, change the SCREEN statement to an appropriate SCREEN mode. SCREEN 9 'The &quot;R&quot; command of the DRAW statement draws a line to the right of 'the current pixel position. The distance traveled is the number 'entered after the command. DRAW &quot;R10&quot;    'No scale factor, line is 10 pixels long. DRAW &quot;S1R10&quot;  '(1/4) * 10 = 3 pixels long (rounded up). DRAW &quot;S2R10&quot;  '(2/4) * 10 = 5 pixels long. DRAW &quot;S3R10&quot;  '(3/4) * 10 = 8 pixels long (rounded up). DRAW &quot;S4R10&quot;  '(4/4) * 10 = 10 pixels long. DRAW &quot;S5R10&quot;  '(5/4) * 10 = 13 pixels long (rounded up. DRAW &quot;S6R10&quot;   '(6/4) * 10 = 15 pixels long. DRAW &quot;S7R10&quot;   '(7/4) * 10 = 18 pixels long (rounded up). DRAW &quot;S8R10&quot;   '(8/4) * 10 = 20 pixels long.

Additional query words: QuickBas BasicCom

Keywords: KB58025

-

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

© Microsoft Corporation. All rights reserved.