[thelist] ASP: Retrieving values from dynamically constructed variable/const names

Jordan Trew JTrew at odyssey.org.au
Tue May 22 23:39:30 CDT 2007

Hi all


This is my first post to a web dev mailing list so let me know if I
break etiquette rules etc..


I'm working on a site using ASP for server side stuff..


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 with pretty long names to be
referred to in this way and want to keep control of access to their
values in the one function so that a statement like:


x = session ("APPLICATION_QUESTIONS")(partCounter, questionCounter,

can be reduced to:


x = CP_GetQuestionAttr (partCounter, questionCounter, ANSWER_TYPE) 


which is easier on eye/brain. It would also help in the case that I
chose to 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 any design choices if
appropriate! I'm a relative beginner.

Cheers, Jordan in Melbourne


More information about the thelist mailing list