[thelist] VARIABLE(s): asp/vbscript (referencing/pointers)

Jonathan_A_McPherson at rl.gov Jonathan_A_McPherson at rl.gov
Wed Jun 26 11:58:01 CDT 2002


The short answer to your question is that the newer VBScript scripting
engines support the Eval() function, which does what you want.


(If "Eval" doesn't work, try "Evaluate" -- been awhile. If neither works,
you have an old scripting engine. Get a new one).

The long answer is that the Eval function is often frowned upon as a
programming evil (like "goto"), and is rather slow besides. How about
something like this?



var myErrMsg = "Meta-error: No valid error message found."

Select Case Request("errMsg")

  Case "C_Err1"
    myErrMsg = "You cannot type. Also, you smell of elderberries."

  Case "C_Err2"
    myErrMsg = "Please fix the errors, or I shall say ... Ni!"

End Select

Response.Write myErrMsg

This isn't too much more work than what you're doing, and avoids the thorns
of Eval.

Jonathan McPherson, LMIT/SD&I
Software Engineer & Web Systems Analyst
email / jonathan_a_mcpherson at rl dot gov

-----Original Message-----
From: Chris W. Parker [mailto:cparker at swatgear.com]
Sent: Wednesday, June 26, 2002 9:34 AM
To: thelist at lists.evolt.org
Subject: [thelist] VARIABLE(s): asp/vbscript (referencing/pointers)


i don't know if "reference" or "pointer" is the right term for what i'm
trying to achieve, so let me just explain.

can i use one variable (say myVar1) to contain the value of another
variable (say myVar2) by holding the name of the second variable? i
think this is a pointer, but i'm not sure so i had a hard time finding
anything through google.

the way i'm trying to use this is by creating a master file that
contains all the error messages that can be used throughout my site as
Constants. i then want to through the querystring (on a redirect if in
an error in a form is found) the name of one of the error message

here is an example...

page1.asp contains the form the user will be filling out and also
include's the error message(s).  the "processing" page called page2.asp
will redirect the user if an error is found in the form with this...


the included file that contains the error messages is defined like so...

Const C_Err1 = "You suck and the form field is blank. Please reenter
Const C_Err2 = "You're ugly, please fix that."

and of course as would be expected, when i
Response.Write(Request("errMsg")) it writes "C_Err1" instead of C_Err1's

how can i get it's value to be printed?

For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

More information about the thelist mailing list