Longer Variable Names Take No Extra Space in .EXE Program (36737)



The information in this article applies to:

  • Microsoft QuickBASIC 1.0
  • Microsoft QuickBASIC 1.01
  • Microsoft QuickBASIC 1.02
  • Microsoft QuickBASIC 2.0
  • Microsoft QuickBASIC 2.01
  • Microsoft QuickBASIC 3.0
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b

This article was previously published under Q36737

SUMMARY

In programs compiled by BC.EXE, you will not change the generated code size by using shorter variable names instead of longer ones. The generated .OBJ and .EXE file sizes are independent of the length of variable names.

Although BC.EXE uses variable names at compile time to allocate memory and translate Basic statements to machine code, these symbolic names are not embedded in the code produced by the compiler.

This information applies to Microsoft QuickBasic Versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50; to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2; and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.

MORE INFORMATION

Source code can be much more readable if you use fully-descriptive names in naming variables. QuickBasic allows variable names up to 40 characters in length. Consider the following choices of variable names:
   mfp     versus      MeanFreePath
   n$      versus      LastName$
   vo      versus      Volts
   vl      versus      Volume
   vc      versus      Velocity
				
The names in the right column generate no more code than those on the left side.

However, within the QB.EXE program development environment, all text in the source file occupies memory, including long variable names.

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB36737