Page

4.6.0- Variable Scope

  by NT Community Manager.
Last Updated  by NT Community Manager.  

PublicCategorized as 04. Variables.

Not tagged.
<< 4.5.1- VBScript ConstantsChapter44.6.1- Local Variables >>

Variable Scope

When we mentioned some of the restrictions on namingvariables at the beginning of this chapter, we neglected to mention one ratherodd requirement that you might have taken for granted. That requirement is thefollowing: that when you name a variable, it should have a unique name.

 

The reasons for avoiding this in the early stages of thischapter are the complications that arise when a piece of code contains twovariables of the same name, because under certain circumstances it isallowed. This doesn't mean, contrary to what we said earlier, that this is apractice you should be indulging in, because it still isn't. However, the ideathat a variable need not have influence over the whole contents of a page, butrather only directly over the part of a page you want to use it for, is apowerful and confers performance enhancements. ASP only has to track it for ashort amount of time, rather than the whole lifetime of a page, it uses lessmemory and when the procedure that uses the variable is over, then the memoryis freed up.

 

It all depends on a rather glib sounding concept known as scope.

<< 4.5.1- VBScript ConstantsChapter44.6.1- Local Variables >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |