forums

TNT Basic Forums > Bugs!
boolean 'and' error
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-20-2002 04:55

Posted by:
Brian Jones

Click Here to Email Brian Jones   Find more posts by Brian Jones

I was having a problem with the following line evaluating to 'true' when I didn't believe it should:

if pressed(key) and lastPressed <> key
...
end if

The ... would be executed when it didn't seem that it should.

After changing this to:

if pressed(key)
if lastPressed <> key
...
end if
end if

The ... no longer executed. I made absolutely no other changes to the code, so I believe this to be an error with TNT Basic rather than on my part. I apologize if that's not correct.

12-20-2002 09:31

Posted by:
John Treece-Birch

Click Here to Email John Treece-Birch   Find more posts by John Treece-Birch

Bug

I think it is a binding problem, if you add brackets like this ...

if (pressed(key)) and (lastPressed <> key)
...
end if

... then I think that should fix it.

I think the problem is that TNT Basic is assuming that the 'and' operator has binding priority i.e ...

if (pressed(key) and lastPressed) <> key

when you actually want the 'not equals' to have binding priority...

if (pressed(key)) and (lastPressed <> key)

To be honest, I'm not sure if this is a problem with TNT Basic because I can't remember the correct operator binding priorities. I'll look them up and make sure TNT Basic is correct.

Thanks,
John

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.