foster74 Posted March 21, 2009 Share Posted March 21, 2009 I need a binary variable to contain multiple Boolean values, I am not sure if it has to do the Bit function as I don't know much about them. I searched the forums to no avail, any help is very much appreciated as always, thank you. Link to comment Share on other sites More sharing options...
Authenticity Posted March 21, 2009 Share Posted March 21, 2009 Define a power of 2 list of flags, for example: Dim $fVisible = 1 Dim $fShiny = 2 Dim $fTiny = 4 . . . Dim $fDUmmy = 0x40 And check it's bit to react upon to: If BitAND($fMask, $fTiny) Then ... Or, am I completely far beyond understanding? Link to comment Share on other sites More sharing options...
foster74 Posted March 21, 2009 Author Share Posted March 21, 2009 (edited) Sorry my description was vague, we are on the right path I believe though. =) How would I go about checking if just one specific value is true? Also how do I generate the $fDUmmy in your question? Sorry I am quite noob with these. Edited March 21, 2009 by foster74 Link to comment Share on other sites More sharing options...
Aceguy Posted March 21, 2009 Share Posted March 21, 2009 binary as in 1 0 1 0 0 1 1 0 1 1 [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Authenticity Posted March 21, 2009 Share Posted March 21, 2009 You can have N flag for N bits variable, so 32 bit int for example contain 32 possible flags instead of declaring 32 boolean variables or 32 int in this matter. I'll try to describe it better as I can: ; These are the properties you may want to determine if are set '1' or aren't '0': Enum Step *2 $fVisible, $fShiny, $fTiny, $fDummy, $fLucky, $fStrike ; A variable that holds a few properties: Dim $fVar = BitOR($fVisible, $fTiny, $fLucky, $fStrike) ; Checking each property, if a property set BitAND result in a value greater then 0, else, 0. ; Same as If BitAND($Var, $fProperty) > 0 Then ...: If BitAND($fVar, $fVisible) Then ConsoleWrite('Visible is set' & @LF) If BitAND($fVar, $fShiny) Then ConsoleWrite('Shiny is set' & @LF) If BitAND($fVar, $fTiny) Then ConsoleWrite('Tiny is set' & @LF) If BitAND($fVar, $fDummy) Then ConsoleWrite('Dummy is set' & @LF) If BitAND($fVar, $fLucky) Then ConsoleWrite('Lucky is set' & @LF) If BitAND($fVar, $fStrike) Then ConsoleWrite('Strike is set' & @LF) Link to comment Share on other sites More sharing options...
foster74 Posted March 21, 2009 Author Share Posted March 21, 2009 binary as in 1 0 1 0 0 1 1 0 1 1Whatever works best, not sure, but had that in mind... But I'd prefer to use a single line of code to figure out if a certain value is 1 or 0 if possible. Like lets say;Value1 = trueValue2 = falseValue3 = trueI'd like to keep these in a single string and use one line to check and/or modify the data. Such as:If Value1 = true Then value1 = false.I hope I'm not confusing anyone. =) Link to comment Share on other sites More sharing options...
foster74 Posted March 21, 2009 Author Share Posted March 21, 2009 (edited) Perfect example Authenticity, exactly what I was looking for, this will help me with storing and parsing data a ton! Thanks a million! =) Edit: Oh a quick follow up question. What's the correct way to deselect a value? If BitAND($fVar, $fTiny) Then $fVar -= $fTiny Is what I am thinking, is there a better way? Edited March 21, 2009 by foster74 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now