WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

UDF - UDS Library
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Bitmask Deciphering UDF

Keywords:   bitmask deciphering listbits UDF

Question:

How do you decipher what a bitmask value is (what bits are set)?

Answer:

#DefineFunction ListBits(bitmask)
	bitstring = ""
	bit = 1
	While bitmask	 ;while there's still a bitmask value
		If bitmask & bit  ;check bit
			bitstring = StrCat(bitstring, bit, @CRLF)
			bitmask = bitmask & ~bit  ;decrement working bitmask number by existing byte increments
		Endif
		bit = bit * 2  ;increment byte
	EndWhile
	
	Return (bitstring)
#EndFunction


bitmask = 10776
;bitmask = -1610612736
bitstring = ListBits(bitmask)
Message("Bits in bitmask", bitstring)

Article ID:   W14985
File Created: 2001:11:08:12:41:18
Last Updated: 2001:11:08:12:41:18