Flags: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
 
Line 4: Line 4:




These flags are always numbers which are binary exclusive and are usually represented as hexadecimals (e.g. const FLAG = &H0001). E.g. for flags with binary values 0001 (&H0001), 0010 (&H0002), 0100 (&H0004) and 1000 (&H0008), we know that the flag value 1011 contains the 1st, 2nd and 4th flag.
These flags are always numbers which are binary, literal values of which usually represented in hexadecimal (e.g. const FLAG = &H0001). E.g. for flags with binary values 0001 (&H0001), 0010 (&H0002), 0100 (&H0004) and 1000 (&H0008), we know that the flag value 1011 contains the 1st, 2nd and 4th flag.


=== Use flags in Visual Basic or VBScript ===
=== Use flags in Visual Basic or VBScript ===

Latest revision as of 13:53, 7 September 2014

What's a flag in programming?

Flags in programming are like tags that can be added to a certain object: they're either present or not.


These flags are always numbers which are binary, literal values of which usually represented in hexadecimal (e.g. const FLAG = &H0001). E.g. for flags with binary values 0001 (&H0001), 0010 (&H0002), 0100 (&H0004) and 1000 (&H0008), we know that the flag value 1011 contains the 1st, 2nd and 4th flag.

Use flags in Visual Basic or VBScript

To add a flag, use OR (Or or +)

MyFlags = MyFlags Or FLAG

To remove a flag, use AND NOT (And Not)

MyFlags = MyFlags And (Not FLAG)

To check for the presence of a flag, use AND (And)

If MyFlags And FLAG
  ' FLAG is present
End If