# ForEachSetBitInBitMask

Grammar — For Each var|Bit in bitMask do (Actions)
FlagsSubFunctions | Action

Executes a For Loop using an integer value. This will run the action set included under the For Each Bit In BitMask for every bit in mask.

# Arguments

  • anyvariable — Integer Variable
  • bitmask — BitMask

Returns — void

#AUTOVAR(g, bitmask) = #PARAM(bitMask);
#AUTOVAR(p) = 0;
#AUTOVAR(bitsFound) = 0;
#AUTOVAR(q) = BitMaskCountOnBits(#AUTOVAR(g));
if (#AUTOVAR(q) != 0) {
    while (#AUTOVAR(bitsFound) != #AUTOVAR(q)) {
        if (BitMaskTrueIndex(#AUTOVAR(g), #AUTOVAR(p))) {
            #AUTOVAR(bitsFound) += 1;
            #PARAM(var) = #AUTOVAR(p);
            #SUBFUNCS(Actions)
        }
        #AUTOVAR(p) += 1;
    }
}

Category: BitMask / Loops

# Examples

— None found —