Which Flag Is Set (ie 1, 2, 4,16,32,64,...)

Discussion in 'AutoCAD' started by Oberer, Feb 4, 2005.

  1. Oberer

    Oberer Guest

    I'm working with some code that deals with the layer states and the optional flag to determine which props to save.

    Initially, I was going to store the sum of the flags using savesettings, until i realized I don't know how to "parse" the total into the individual flags. Could someone give a hint or a little code?

    TIA!
     
    Oberer, Feb 4, 2005
    #1
  2. Oberer

    fantum Guest

    If RetrievedValue And acLSFrozen Then
    'acLSFrozen bit is set
    End If

    If RetirevedValue And acLsColor Then
    'acLsColor bit is set
    End If
     
    fantum, Feb 4, 2005
    #2
  3. Oberer

    Jürg Menzi Guest

    Hi Oberer

    This function returns the bitwise AND:
    Code:
    Public Function MeBitwAnd(FstVal As Integer, NxtVal As Integer) As Boolean
    
    MeBitwAnd = (((FstVal And NxtVal) = NxtVal) Or (FstVal = 0))
    
    End Function
    
    Samples:
    ?MeBitwAnd(9, 8)
    True
    ?MeBitwAnd(9, 2)
    False

    Cheers
     
    Jürg Menzi, Feb 5, 2005
    #3
  4. Oberer

    Oberer Guest

    I obviously didn't realize it was that simple :)

    thanks!
     
    Oberer, Feb 7, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.