[comp.databases] Clipper and bitwise operators

b39y@vax5.cit.cornell.edu (06/14/91)

I've got a question for Clipper users.  I'm running in Clipper 5.01, and want
to use a bitmask-style integer for checking access to parts of my code.  That
is, I'd like to assign (at startup) values like SCHEDULE && ACCOUNT &&
BIOGRAPHICAL (where the constants have been #defined as 1, 2, and 4
respectively) to a numeric nAccess.  Then, when entering my account module, I'd
like to check like this:

	if nAccess .and. ACCOUNT
	   accounting code here
	else
	   ERROR:  You have insufficient priviledges for this operation
	endif

However, Clipper has no bitwise operators that I can find.  Am I missing them,
or do they truly not exist?  If they don't exist, has anyone got suggestions
for alternative implementations?  Thanks

Dave Rodger
Applications Programmer, Cornell University

jgb@prism.gatech.EDU (James G. Baker) (06/14/91)

In article <1991Jun13.142852.5436@vax5.cit.cornell.edu> b39y@vax5.cit.cornell.edu writes:
>I've got a question for Clipper users.  I'm running in Clipper 5.01, and want
>to use a bitmask-style integer for checking access to parts of my code.  

I assume they did not want bit-wise operators since having a binary byte 
(usually less than 32) in a .DBF can mess things up (like a stray EOF, etc).

You could interface some C functions to do it, but (if it were me) I would
just use a character mask instead of a bit-mask.  It might take eight
bytes instead of 1, but it sure makes debugging easier and memory is 
cheap.

Good luck.


-J Baker
-- 
BAKER,JAMES G - Undergraduate Lab Instructor, School of Electrical Engineering
____  _    _    Georgia Institute of Technology, Atlanta Georgia, 30332
  |  | _  |_)   uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!jgb 
(_|. |_). |_).  Internet: jgb@prism.gatech.edu, jgb@ee, jgb@eecom, jgb@cc

b39y@vax5.cit.cornell.edu (06/14/91)

In article <31346@hydra.gatech.EDU>,
jgb@prism.gatech.EDU (James G. Baker) writes: 
> In article <1991Jun13.142852.5436@vax5.cit.cornell.edu> b39y@vax5.cit.cornell.edu writes:
>>I've got a question for Clipper users.  I'm running in Clipper 5.01, and want
>>to use a bitmask-style integer for checking access to parts of my code.  
> 
> I assume they did not want bit-wise operators since having a binary byte 
> (usually less than 32) in a .DBF can mess things up (like a stray EOF, etc).
> 
> You could interface some C functions to do it, but (if it were me) I would
> just use a character mask instead of a bit-mask.  It might take eight
> bytes instead of 1, but it sure makes debugging easier and memory is 
> cheap.
> 
> Good luck.
> 
> 
> -J Baker

James -

Thanks; I probably will take the character route for this situation, or some
similar thing.  I was also told that some third-party libraries have these
operations available, so if I *need* them in the future, it's nice to know
where to get them.

Dave

tleylan@pegasus.com (Tom Leylan) (06/15/91)

In article <1991Jun13.142852.5436@vax5.cit.cornell.edu> b39y@vax5.cit.cornell.edu writes:
>
>However, Clipper has no bitwise operators that I can find.  Am I missing them,
>or do they truly not exist?  If they don't exist, has anyone got suggestions
>for alternative implementations?  Thanks
>
Dave,  Bitwise operations can be done quite easily in Clipper.  The simple
solution is to download the Nanforum Toolkit from Nantucket's forum on
Compuserve.  It is a compilation of many functions donated by Nanforum
members and contains the bitwise operations that you are looking for.

The Nanforum Toolkit is public domain and source code is included.

Among the best routines in FT_Int86() which is an Int86 function written
in assembler permitting Clipper programmers to call DOS interrupts directly
from Clipper by simply loading an array and calling the function.

tom