Print Page | Close Window

Declaring variables in one common asp pag

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9796
Printed Date: 31 March 2026 at 6:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Declaring variables in one common asp pag
Posted By: roverroad
Subject: Declaring variables in one common asp pag
Date Posted: 13 February 2004 at 12:17am
I know that it's considered sloppy programming to declare a variable on a page if you aren't going to use it, but what happens if you do it? Does it end up costing more bandwidth the more variables that are declared or is it just that it's sloppy to do so?

The reason that I ask is because I want to keep track of all of my variables on one common page instead of declaring them on each individual page. This will help me keep track of what variables I have on my site and what they are being used for.

But if I do this all of the variables will be declared at once, even when they aren't needed.

What are the consequences of this going to be?

-------------
http://www.AnswerPlanet.info is coming soon.



Replies:
Posted By: Demon
Date Posted: 13 February 2004 at 1:01am
I think it is going to use bandwidth becuase bandwidth is calulated by file size, and when you open the file, it goes through the entire code and checks it out.  So any extra declarations or anything in the file which increases it's file size will cost a lil bandwidth(depending on how much the extra declarations add up to in filesize.)  lol.  *takes breath*


Posted By: roverroad
Date Posted: 13 February 2004 at 1:14am

Good point.  I got to thinking about a different way that I could do it.  I still want to declare all of my variables on one page but if I have a variable like this on every page:

Dim strPageName

strPageName = "debug.asp"

<!--#include file="variables.asp" -->

Then on the variables page use

If strPageName = "debug.asp" then Dim strGroupName

That may cut down on the bandwidth because I don't think it will read the portions of the variables that do not meet the If criteria.

I know it sounds strange what I want to do, but I've done a lot of customization and am finding it difficult to keep track of all of my variables.  This was the best way that I could think of to start organizing.



-------------
http://www.AnswerPlanet.info is coming soon.


Posted By: pmormr
Date Posted: 13 February 2004 at 2:48pm

except when an asp page is processed the file size does not determine the bandwidth used, the file output does. so declaring a useless variable would only use up memory on the server while the processing of the page is running (since all accumulated memory is released at termination of the processing) for example, this page would have a relatively small file size, but would consume a hell of a lot of bandwidth (and cpu cycles)...

Dim myVar
While(True)
   myVar = myVar + 1
   Response.Write myVar
Wend

not only would that send millions of lines to the remote user, but would eventually kill your computer, causing it to use all it's memory... (CAUTION: DO NOT RUN THAT CODE!)



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Mart
Date Posted: 13 February 2004 at 3:39pm

Just a simple

For i = 1 To 1000000

Response.Write("Hello" & vbCrlf)

Next

Will killl your server



Posted By: roverroad
Date Posted: 14 February 2004 at 11:54pm
Yikes, and if I'm on a shared server that would really cause problems.  Point well taken. 

-------------
http://www.AnswerPlanet.info is coming soon.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net