BinaryAnd

Performs a bitwise AND on portions of two binary buffers.

Syntax:

BinaryAnd( target-handle, target-offset, source-handle, source-offset, count )

Parameters:

(i) target-handle: handle of target buffer.

(i) target-offset: zero-based offset into the target buffer specifying where the data to be processed starts, and where the result of the operation should be placed.

(i) source-handle: handle of source buffer.

(i) source-offset: zero-based offset into the source buffer specifying where the data to be processed starts.

(i) count: the number of bytes to process.

Returns:

(i) Returns 1.

 

The specified sections of the buffers are processed on a byte-by-byte basis, and the results are written to the buffer specified by "target-handle". i.e., the byte at "source-offset" is AND'ed with the byte at "target-offset", and the result of the AND operation is stored in the byte at "target-offset", then the bytes at "source-offset + 1" and "target-offset + 1" are AND'ed, and so on.

"target-handle" and "source-handle" may both reference the same buffer, in which case two sections of the buffer can be processed.

Example:


buf1 = BinaryAlloc(10)
buf2 = BinaryAlloc(10)
For i = 0 To 9
   BinaryPoke(buf1, i, 5) ; this stuffs 5's into buf1
   BinaryPoke(buf2, i, 6) ; this stuffs 6's into buf2
Next
rc = BinaryAnd(buf1, 0, buf2, 0, 3) ; This replaces values in buf1
a=BinaryPeek( buf1, 0 )
b=BinaryPeek( buf1, 1 )
c=BinaryPeek( buf1, 2 )
d=BinaryPeek( buf1, 3 )
e=BinaryPeek( buf1, 4 )
BinaryWrite(buf1, "zzbin1.txt") ; if you want to see the values
BinaryWrite(buf2, "zzbin2.txt") ; you can write it out with BinaryWrite
; AND LOGIC:
; 5 = 0101
; 6 = 0110
; ========
; 4 = 0100 = result
Message("Variables a, b, and c should now = 4", "a = %a%%@crlf%b = %b%%@crlf%c = %c%%@crlf%")
See Also:

Binary Operations, BinaryAlloc, BinaryCopy, BinaryFree, BinaryRead, DllCall, BinaryCompare