[thelist] Bitwise Logic Tip [WAS: job (NYC - USA) Contract - .net developer 4month as signment]

Chris at globet.com Chris at globet.com
Fri Jul 29 04:33:34 CDT 2005


Arthur

> > Insn't this the second time you've spammed the list for your 
> > employment needs? specifically this job?
> Rob:
> 
> I specifically asked the the e-volt website and list managers 
> whether or not it is permissible to post jobs on the list 
> while the web site is being moved.
> 
> I was told it is permissible.

There is a difference between permissible and appropriate. It is
*permissible* for me to harrangue passers-by on Oxford Street through a
bullhorn on the subject of religion - I do not find it *appropriate* to
do so :)

Tips are owed, I would suppose.

<tip type='VBScript'>

After validating an HTML form, multiple errors can be represented by a
single integer using bitwise logic.

Thus if I have 4 form fields to validate, and wish to record which have
valid values:

<%
Dim iErrors : iErrors = 0
Dim iError1 : iError1 = 1 'bit 1
Dim iError2 : iError2 = 2 'bit 2
Dim iError3 : iError3 = 4 'bit 3
Dim iError4 : iError4 = 8 'bit 4

'Validate form, assigning boolean values to
'variables indicating validation success 
'for each of 4 form fields.

If bIsError1 Then iErrors = (iErrors Or iError1)
If bIsError2 Then iErrors = (iErrors Or iError2)
If bIsError3 Then iErrors = (iErrors Or iError3)
If bIsError4 Then iErrors = (iErrors Or iError4)
%>

The integer iErrors can then be sent wherever necessary, and then used
thus:

<%
If (iErrors And iError1) = iError1 Then Response.Write "Error 1 has
occurred<br />"
If (iErrors And iError2) = iError2 Then Response.Write "Error 2 has
occurred<br />"
If (iErrors And iError3) = iError3 Then Response.Write "Error 3 has
occurred<br />"
If (iErrors And iError4) = iError4 Then Response.Write "Error 4 has
occurred<br />"
%>

</tip>

Chris Marsh
Web Developer
http://www.globet.com/
Tel: +44 20 8246 4804 Ext 828
Fax: +44 20 8246 4808

Any opinions expressed in this email are those of the individual and not
necessarily the Company. This message is intended for the use of the
individual or entity to which it is addressed and may contain
information that is confidential and privileged and exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly prohibited.
If you have received this communication in error, please contact the
sender immediately and delete it from your system. 


More information about the thelist mailing list