well I can't say exactly why it was done this way in the first place - I
guess its like most things in programming, there's more than one way to do
things so the programmer chooses a way which they are comfortable with, or
perhaps likes to try something new. Who knows?
Using bit flags is a common enough method if you think of the
alternatives. Say you have load of boolean values you want to store, each
one will probably take up 32 bits (depending on the OS) and you'll have a
different variable name for each one. Compare that with using bit flags
where you can store, say, 31 booleans in a single 32 bit integer.
As to your second question, yes it will skip some of the code because of
failing tests like flag&2. Interesting variation here is that since each
test appears to have (flag&0) || (flag&..) this means that 0 is the same
as having all switches ON.
Phil
> Everything you said makes sense except for the programmers motivations.
>
> I have located some calls to one of these functions where the flag is
set to other values than
> zero. Is this supposed to be an index into the function, skipping code
that he doesn't want
> executed under certain conditions?
>
> For instance on onunload="ReCalc(frm,254)". Does this skip some of the
code because of
> failing the second part of some of the IF statements ( if(flag==0 ||
((flag&2)>0)))? Is that what