ngdrummer wrote
oh i think i see problem, do i need to write while(~(selected)) instead of selected = false?
Yes, that's correct.
The problem is that using = to compare booleans can be quite problematic, so you should never do it.
boolean is generally defined as zero means false and all non-zero values mean true. The constant
true is defined as -1.
boolean b;
let b=7;
if (b) {
// this code happens
}
if (b=true) {
// this code doesn't happen!
}
--Mark