IF bug THEN tell me
Archives Forums/Blitz3D Bug Reports/IF bug THEN tell me
| ||
This works ok..... If (psl And 16) Then rs=1 Else rs=0 If rr<>0 And rs=1 Then rr=rr+3 This doesnt work.... If rr<>0 And (psl And 16) Then rr=rr+3 If (psl And 16) Then rs=1 Else rs=0 it should work but why doesnt it????? |
| ||
PS just to explain what im trying to achieve; I am trying to add 3 to 'rr' when (psl and 16) isn't zero |
| ||
If rr<>0 And (psl And 16)<>0 then rr=rr+3. Because And does not do a logical comparison, it does a bitwise And, so your test will fail to do what you want because it is Anding bit 1 from the rr>0 comparison with a bit set at position 5 from the (psl And 16) operation.. This will result in zero. So you change that operation into a comparison as above, or you could do a Shr to shift the bit into the right position so: If rr<>0 And (psl And 16) Shr 4 Then... which will also work in this instance. |
| ||
Thanks for help, my confidence has been restored! |