For Programmers: Free Programming Magazines  


Home > Archive > ASP > July 2004 > boolean expression evaluation algorithm









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author boolean expression evaluation algorithm
Simon Wigzell

2004-07-24, 8:55 pm

A client wants have acess to an online databases records controlled by group
strings and evaluation strings e.g., each use would have in his client
record a group string like this:

[ROOT][ADMIN][ACCOUNTING][ABC PRODUCTS]

And each record in a database would have an evaluation string like this :

([ROOT] OR [ADMIN] OR [ACCOUNTING] OR [FINANCE]) AND [ABC PRODUCTS] OR
[ACME]) etc.

No limit to the number of groups or the complexity of the evaluation
expression. I need an asp function that I will just pass the group string
and the evaluation string and it will return True or False as to whether the
client can view that particular record. I can't find anything in ASP on the
internet though this must be a common database control method for
non-browser applications? Has anyone done anything like this in ASP? Thanks!


Bullschmidt

2004-07-27, 8:55 pm

<<
A client wants have acess to an online databases records controlled by
group
strings and evaluation strings e.g., each use would have in his client
record a group string like this:

[ROOT][ADMIN][ACCOUNTING][ABC PRODUCTS]

And each record in a database would have an evaluation string like this
:

([ROOT] OR [ADMIN] OR [ACCOUNTING] OR [FINANCE]) AND [ABC PRODUCTS] OR
[ACME]) etc.

No limit to the number of groups or the complexity of the evaluation
expression. I need an asp function that I will just pass the group
string
and the evaluation string and it will return True or False as to whether
the
client can view that particular record. I can't find anything in ASP on
the
internet though this must be a common database control method for
non-browser applications? Has anyone done anything like this in ASP?
Thanks![color=darkred]

Here's something like what I've often used to make sure someone is
allowed to view a page:

' If not valid user level.
If Not jpsvbIsInList("User;Admin", Session("UserLevel"), ";", True) Then
Response.Redirect mstrSiteMainSecure & "/login.asp"
End If

And later in the page's SQL statement I might actually used the CustID
of the user too.

And here is the custom jpsvbIsInList() function:

Function jpsvbIsInList(pvarList, pvarItem, pstrSeparator,
pbolIsCaseSensitive)
' Purpose: See if item is in list.
' Remarks: Typical separator can be ; or even multiple chars such as
comma space.

' Dim var.
Dim varItem
Dim varList
Dim intCompare

' Set var.
' (Uses VB constants.)
varItem = CStr(pvarItem)
varList = CStr(pstrSeparator & pvarList & pstrSeparator)
If pbolIsCaseSensitive Then
intCompare = vbBinaryCompare
Else
intCompare = vbTextCompare
End If

' Return val.
If InStr(1, varList, pstrSeparator & pvarItem & pstrSeparator,
intCompare) > 0 Then
jpsvbIsInList = True
Else
jpsvbIsInList = False
End If
End Function

Hope this helps,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com