Core Function HasFlagAny

From Sputnik Wiki
Jump to: navigation, search
HasFlag( <enumInst>, <flags>... )

Contents

Description

Check if any flag is enabled in a given enum instance.

Parameters

enumInst

Instance of an enum (or any integer will do)

flags

One or more enum flags (or integers)

Return Value

Success: Returns true

Failure: Returns false

Remarks

This is just an easier way to do bit flags.

Example

enum Options {
    $OPT_A = 0x01,
    $OPT_B = 0x02,
    $OPT_C = 0x04,
    $OPT_H = 0x08
};
 
$opt = Options->$OPT_A;
say "HasFlagAny 'A' or 'C' : " . HasFlagAny($opt, Options->$OPT_A, Options->$OPT_C);
say "HasFlagAny 'C' or 'B' : " . HasFlagAny($opt, Options->$OPT_C, Options->$OPT_B);
 
// PRINTS
// HasFlagAny 'A' or 'C' : true
// HasFlagAny 'C' or 'B' : false
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox