Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / And is ok but && has issues.

Author
Message
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 17th Oct 2018 22:42
when coding I had a strange error where I was testing a bounding box area with && and checking the mouse position in the box, I was getting a positive anywhere aligned with either the box x and y coordinates.

After much head scratching I changed && for And now it works perfectly as expected.

it's just a simple:
global mx as integer
global my as integer

repeat
if mx>0 and mx <50
if my>0 and my <50
print( "In zone")
endif
endif

sync ()
until v <>0

change the and in each if statement for && it compiles but flags in zone anywhere in line with the area.
-EdzUp
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 17th Oct 2018 22:46
puzzler2018
User Banned
Posted: 17th Oct 2018 22:48 Edited at: 17th Oct 2018 22:50
Works perfectly as expected you say - so whats query - and && is c++ or c# operands. are we working with Tier 2
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 17th Oct 2018 22:56
&& is a Tier1 bitwise operator as well
puzzler2018
User Banned
Posted: 17th Oct 2018 22:57 Edited at: 17th Oct 2018 22:59
missed that one - cheers

ill go back to the memblock work
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 18th Oct 2018 15:26 Edited at: 18th Oct 2018 15:31
Yeah, that one confused me too, as I'm used to && being just a boolean this way ;

0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1

I suppose the other script language I was previously using didn't quite use it the proper way. As I always assumed AND and && to work the same way. Learning new things lol!

I've long since changed my code, but I am pretty sure I had a similar issue with using <> and if NOT ;

if not X = excluded_value
// do something
endif

instead of say:

if X <> excluded_value
// do something ...
endif
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 6th Nov 2018 13:55
Ah I read somewhere that it can be used like and in if statements 'if x =1 and y=2' etc but if its a bitwise and then I will stick with and from now on
-EdzUp

Login to post a reply

Server time is: 2024-11-23 11:47:21
Your offset time is: 2024-11-23 11:47:21