"Off Topic" as this seems to be a JavaScript problem
I am expecting only the first case statement to be hit in the code below.
But all of them are hit.
Why?
I know there are no break statements that is on purpose.
I want code to be run if the relevant bit is set.
In the example below only bit 1 is set.
If the variable is, say 3, (Binary 0011) then I want the fist 2 case statements to hit.
Etc.
function OnClick(clickData)
{
// --------------------------------------------------------
DOpus.ClearOutput();
// --------------------------------------------------------
var FeatureMask = 0x1;
DOpus.Output("000-010 FeatureMask START :" + ZeroPad(FeatureMask.toString(2),4));
DOpus.Output("")
switch(FeatureMask)
{
case (FeatureMask&0x1):
DOpus.Output(" 004000-200-000 Case FeatureMask&0x1 ---C = " + ZeroPad(FeatureMask&0x1.toString(2),4));
DOpus.Output(" 004000-200-000 Case FeatureMask ---C = " + ZeroPad(FeatureMask.toString(2),4));
DOpus.Output("");
case (FeatureMask&0x2):
DOpus.Output(" 004000-220-000 Case FeatureMask&0x2 --B- = " + ZeroPad(FeatureMask&0x2.toString(2),4));
DOpus.Output(" 004000-220-000 Case FeatureMask --B- = " + ZeroPad(FeatureMask.toString(2),4));
DOpus.Output("");
case (FeatureMask&0x4):
DOpus.Output(" 004000-240-000 Case FeatureMask&0x4 -A-- = " + ZeroPad(FeatureMask&0x4.toString(2),4));
DOpus.Output(" 004000-240-000 Case FeatureMask -A-- = " + ZeroPad(FeatureMask.toString(2),4));
DOpus.Output("");
case (FeatureMask&0x8):
DOpus.Output(" 004000-280-000 Case FeatureMask&0x8 F--- = " + ZeroPad(FeatureMask&0x8.toString(2),4));
DOpus.Output(" 004000-280-000 Case FeatureMask F--- = " + ZeroPad(FeatureMask.toString(2),4));
DOpus.Output("");
default:
DOpus.Output(" 004000-400-010 FeatureMask Default = " + ZeroPad(FeatureMask.toString(2),4));
}
// --------------------------------------------------------
}
function ZeroPad(s,c)
{
s = s + "";
while(s.length < c)
{
s = "0" + s;
}
return s;
}
In this example below