Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a string as an IF statement for validation....possible? 1

Status
Not open for further replies.

treyball3

Programmer
Jun 20, 2001
74
US
Ok, so the subject doesn't really make sense, but I didn't know how to sum it up very well. Here's what I want to do, and hopefully its possible.

I want to be able to pull a validation rule from the DB and store it in a variable. The reason for this is because the rules could change and we don't want to have to change the code all the time to accommodate. So basically, I want to have a string set to an expression and then use that string for an IF statement, like follows...

Code:
sStringFromDB = "nCategoryID = ""1000"""

if sStringFromDB then
    'Do Something
end if

and basically what I want that to do is

Code:
if nCategoryID = 1000 then
    'Do Something
end if

Is this even possible?? and if so, how do I go about doing that??



Thanks - Todd
 
is it just the int value that can change, or the name of the variable too?

if the former, couldn't you just use:
Code:
intFromDB = "1000"

if nCategoryID = intFromDB then
    'Do Something
end if

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
well, the whole validation could change. I was just using a simple example. It could be anything like the following...

Code:
sStringFromDB = "(cint(sVariable) > cint(200) or cint(sVariable) < cint(100))"

sStringFromDB = "nCategoryID = ""1000"""

...and since this can change to whatever to be able to validate a field, I'm hoping I can figure something out for this.



Thanks - Todd
 
dynamic form fields
Code:
for each x in request.form 
'   add in some ifs to ignore the submit buttom
' do processing     
next

where;
x = Name of form field
request.form(x) = value of field




Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Thanks Jeff!

The eval() function was just what I needed!

(star for you)



Thanks - Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top