Page

9.3.3- Use Option Explicit

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

PublicCategorized as 09. Error Handling.

Not tagged.
<< 9.3.2- Comment Your CodeChapter99.3.4- Use Subprocedures >>

Use Option Explicit

Back in Chapter 4 we mentioned this, and it really is worth using – especially if your typing is as bad as mine! If you remember, it justforces you to declare all of your variables before you use them, and it willforce an error to be generated if you use a variable that hasn't been declared.

 

It's simple to use. For server-side script, just put thefollowing line at the beginning of your ASP file, following the language andbuffer tags:

 

<% Option Explicit %>

 

For client-side script you can add it at the beginning ofthe script:

 

<SCRIPT LANGUAGE=VBScript>

  Option Explicit

  . . .

</SCRIPT>

 

That's all there is to it, and it saves a lot of timehunting for those little typing mistakes. One thing to remember is that onceyou've completed your debugging and removed all of the typos, then you canremove Option Explicit;otherwise it may slow down your server.

<< 9.3.2- Comment Your CodeChapter99.3.4- Use Subprocedures >>

Copyright © 2003 by Wiley Publishing, Inc.

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