Witango's @CALC does not support bitwise operations (as far as I know).

 

My first suggestion is to look to another language eg. server-side
javascript or perhaps through an external command line action or COM object.

 

My second suggestion is to see if you can do these operations completely in
your database. Likely possible, but a little cumbersome.

 

Third, is a method I sometimes use for permissions that works in a similar
way, but is slower and a little archaic:

 

Instead of assigning permissionTaskA = 1, assign = A

Instead of assigning permissionTaskB = 2, assign = B

 

Then store in the user_permissions column string 'ACDEF'

 

Then 

 

select row from table where user_permissions like '%A%' = true

select row from table where user_permissions like '%B%' = false

 

this has the same net result with up to 26 permission types (more if you
want to use numbers and special characters)

 

Obviously this is slower due to the fact that working with characters is
slower than working with bits, but on modern hardware I think the difference
is nominal.

 

Hope that helps.

 

If you find a good way to do bitwise operations - please post it.

 

Robert

 

  _____  

From: John Hotaling [mailto:jhotal...@auctionanything.com] 
Sent: Friday, July 03, 2009 2:53 PM
To: witango-talk@witango.com
Subject: Witango-Talk: Bitwise Operators and Enumeration

 

Hello:

Is anybody using Witango for something like the following?

http://www.johnsample.com/articles/BitwiseEnums.aspx

In general, I want to test for the following in Witango using the above
referenced bitwise operator logic:

<@ASSIGN NAME="PermissionForTaskA" value="1">

<@ASSIGN NAME="ThisClientsPermissions" value="33">

Does this client have permission to do Task A?  In this case, Yes is the
answer.

 

<@ASSIGN NAME="PermissionForTaskB" value="2">

<@ASSIGN NAME="ThisClientsPermissions" value="33">

Does this client have permission to do Task B?  In this case, No is the
answer.

 

For example, if you had an integer column called ThisClientsPermissions with
a value of 33, you could use the following statement to return the row if it
has  PermissionForTaskA (1) 

select row from table where (PermissionForTaskA & 1 > 0) 

Can the calc metatag assist with this type of logic?

Thank you in advance for any assistance/insight.

John Hotaling

AuctionAnything.com, Inc.

 



________________________________________________________________________

TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to