Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Why using const?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Why using const?

 Post Reply Post Reply
Author
efscl View Drop Down
Newbie
Newbie


Joined: 13 May 2007
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote efscl Quote  Post ReplyReply Direct Link To This Post Topic: Why using const?
    Posted: 13 December 2007 at 1:32pm
Hi Borg, Hi Senior ASP Programmers,

in the forum you are using "const" at different places.

1.) I know this is a "clean" programmning.
2.) Sometimes its written that constants have a better performance than variables
3.) if you would that a variable never will change: use constant

Problem:
I am using one test server and one live server with "the same" code.  So i have to change for example in functions_member_API.asp the

const strMemberAPILoginURL = "http://test.liveserver.com/login.asp"
to
const strMemberAPILoginURL = "http://www.liveserver.com/login.asp"

You writting in the comment above the code that i have to use the full URL "http://..." and not  "/login.asp".

But manually change everytime is not a good choice.

Const s
trMemberAPILoginURL = "http://" & Req.SV("HTTP_HOST") & "/login.asp"

is not working with Const. So i have to use a variable.

Ok - now the question Smile:
Is there any other important reason for using a constant instead of a variable?

thx all for your feedback
Sebastian

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 13 December 2007 at 1:45pm
The only reason is for clean programming and because it's meant to give better performance.

So that the variable can be assigned different values just declare the variable using a Dim line and then remove the Const.
Back to Top
efscl View Drop Down
Newbie
Newbie


Joined: 13 May 2007
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote efscl Quote  Post ReplyReply Direct Link To This Post Posted: 13 December 2007 at 1:53pm
again: faster reply than the fire departement allows ;O)

thx n have a great day
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.