Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Declaring variables in one common asp pag
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Declaring variables in one common asp pag

 Post Reply Post Reply
Author
roverroad View Drop Down
Newbie
Newbie
Avatar

Joined: 01 January 2004
Location: United States
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote roverroad Quote  Post ReplyReply Direct Link To This Post Topic: Declaring variables in one common asp pag
    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?
Back to Top
Demon View Drop Down
Mod Builder Group
Mod Builder Group
Avatar
Mod-n-Skin Moderator

Joined: 26 July 2003
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote Demon Quote  Post ReplyReply Direct Link To This Post 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*
Back to Top
roverroad View Drop Down
Newbie
Newbie
Avatar

Joined: 01 January 2004
Location: United States
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote roverroad Quote  Post ReplyReply Direct Link To This Post 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.



Edited by roverroad
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post 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!)

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 13 February 2004 at 3:39pm

Just a simple

For i = 1 To 1000000

Response.Write("Hello" & vbCrlf)

Next

Will killl your server

Back to Top
roverroad View Drop Down
Newbie
Newbie
Avatar

Joined: 01 January 2004
Location: United States
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote roverroad Quote  Post ReplyReply Direct Link To This Post Posted: 14 February 2004 at 11:54pm
Yikes, and if I'm on a shared server that would really cause problems.  Point well taken. 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.