Function Parameters

I got an external Library and I found something interesting in their Xojo/RB example.

There are a bunch of Constants

CONSTANT_01 = 2 CONSTANT_02 = 4 etc.
and then a Function is Called like this:

aFunction(CONSTANT_01 Or CONSTANT_02)

^ watch the ‘Or’

And the Function looks like this:

[code]Sub aFunction(Optional flags As UInt32 = CONSTANT_01)

Declare Function aFunction Lib aLibrary(ByVal flags As UInt32) As Int32

Dim ret As Int32 = aFunction(flags)

Select Case ret
Case 0 ’ success
Return
Case 8
Raise New someException
Case 15
Raise New someOtherException
etc…[/code]

I had no idea that a Function could be called like this.
Within the function, it seems that the constants are added (flags = 6).
But when I change the ‘Or’ (in the Function Call) to ‘And’, flags = 0.

Is this something handy I missed? How is this normally used? Are there examples in the documentation that explains this and show where this could be useful?

http://documentation.xojo.com/index.php/And
http://documentation.xojo.com/index.php/Not
http://documentation.xojo.com/index.php/Or
http://documentation.xojo.com/index.php/Xor

aFunction(CONSTANT_01 Or CONSTANT_02)

takes 2 (integer) OR 4 (integer)

Bitwise OR of 2 and 4 gives 6

2 => &b010
4 => &b100
----------------
     &b110 => 6

You set the bit in the result if it is set in one OR the other

Thanks Norman

This change to make AND OR NOT XOR also do bitwise operations on integers happened quite a few years back