Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 21st, 2007, 01:24 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically accessing ASP variables

Hi folks

I need to find a way, if there is one, to retrieve ASP variable values in the following way:

Const FIELD_SIZE = 10
Const FIELD_NAME = "FirstName"
response.write ("<input type=text size=" & getFieldAttr("SIZE")& " name=" & getFieldAttr("SIZE") & ">Some name")

function getFieldAttr (attr)
    getFieldAttr = XX code to retrieve the constant with name "FIELD_" followed by the value of attr XX
end function


I realise this can be done using session variables, whose names can easily be constructed from concatenating strings, but I would prefer to avoid session variables in this case if possible. It might seem useless but I have a large number of constants to be referred to in this way and want to keep central control of access to their values in the one function (eg in case i change the naming convention for the const's). Am happy to incorporate js into this if necessary, since its a local site and only used by me. Thanks. Feel free to criticise my design choice if appropriate! I'm a relative beginner.

 
Old May 21st, 2007, 02:09 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Additionally, it allows me to reduce a statement like:

x = session ("APPLICATION_QUESTIONS")(part, questionCounter, APPLICATION_QUESTIONS_ANSWER_TYPE)

with
x = CP_GetQuestionAttr (part, questionCounter, ANSWER_TYPE)

where the CP_GetQuestionAttr function returns the value. which is easier on the eye/brain :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing server variables badgolfer Classic ASP Professional 2 October 23rd, 2007 03:11 AM
getting asp variables dynamically marco_1 Classic ASP Basics 13 December 11th, 2006 05:39 PM
Accessing Session Variables in javascript subhendude Other Programming Languages 1 November 8th, 2006 11:15 AM
accessing variables in templates austinf XSLT 1 May 4th, 2006 03:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.