|Combining Flags, "+" or "OR"|
(2/26/00 5:16:42 pm)
This might be a silly question, but here it goes:
if you want to combine flags like
dim DDSD as DDSURFACEDESC2
most of the time I see "Or"
instead of "+"
(2/26/00 6:21:30 pm)
I really have no idea. I just always use Or.
(2/27/00 3:20:08 pm)
Or is technically the 'better' way..... I haven't really checked it out, but flags are MEANT to be combined using a binary operation just because of their nature.....
(2/27/00 8:56:36 pm)
There is a HUGE difference between "or" and "+."
Or combines binary flags, "+" add thems.
flag = 1
if you do "flag + flag" then you'll get 2. If you do "flag or flag", which means (for this example) 1 or 1, then that's a big difference.
I'll use the example from the directX sdk.
red = 1
purple = red or purple 'which
makes sense, purple = red OR purple = purple. Obviously purple = purple,
but only one of the statements has to be true for the whole thing to be
true. purple equals one or the other.
I'll show you in binary form, which is where the power of the boolean operations comes from.
(I'm using 4 bits here)
red or blue is this
red or red is this
red + red is this
I hope that helps.
Thanks for the example, but
I've got one problem:
I think I will type "+" to get the dropdown box and replace it with "Or" if I'm done.
(2/29/00 9:55:59 am)
OR combines bits.
Everything below this line is from the SDK.................
Many object methods in DirectX for Visual Basic take a flags parameter, or a parameter with a similar name. Also, some types have a member containing flags. Flags are used to control miscellaneous aspects of the behavior of method calls or to report details about things like device capabilities.
A flag is a single bit of information. It dictates or reports whether a certain behavior or capability is present or absent. A set of related flags is represented by an enumeration whose members generally do not share any bits. (Some flags, however, may represent combinations of other flags.)
Because flags represent single bits, multiple flags can be combined in a single value. For example, suppose you wanted to set the cooperative level of a DirectInput device to both foreground and exclusive. You would do so by combining two flags, using a logical Or operation, as follows:
' diDevice is a DirectInputDevice
object, and hwnd is a window handle
Dim Color As Integer
The following operation, on the other hand, sets an incorrect value:
' This is wrong!
When you retrieve a value for flags, you can extract the setting of an individual flag by using a logical And operation. If the flags value contains the bit represented by a flag constant, the And operation returns a nonzero value and that flag is "on". If the And operation returns zero, the flag is "off". For example, the following call determines whether an input device, whose capabilities have been retrieved in a variable of type DIDEVCAPS, is physically attached to the system:
Dim IsAttached As Boolean
' This is wrong!
(3/2/00 11:02:12 am)
Thanks, the only thing I guess I didn't know/understand from your previous message was that purple was a combination off the other flags..
But since this was for silly questions, here's another one:
What exactly is the SDK?
I've just downloaded a help file form MSDN, is the SDK better? (I guess it should be for 128(?)MB )
SDK is a Software Development Kit, it exists for alot of API's like DirectX, Java etc. and is a kit of tools, code, maybe samples to help people get started with development.
The DirectX7 SDK is about
128 MB I think, and it contains DX7 Runtime files, DX for VB library, C++
and VB sourcecode, SDK documentation and some DirectX utilities.