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 / BUG:Not operator fix breaks compatibility

Author
Message
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 4th Feb 2015 01:45
Hi Paul,

Ok, so you made a fix to the ! operator, but that has broken compatibility with the code that is compiled in V2.0.11.

A standard way of programming is to use the ! when testing a condition.

For example.

Value = 100
if (!Value) then doSomething()


So for example





I would not expect the print statement to execute, but what it is doing now is saying the !100 is = -101 and therefore the condition executes.

The statement should only execute when value = 0, i.e. NOT ZERO

Is this intentional and do I need to change all my lines of code to be if(var = 0) ?

Kind Regards
Jason

https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 4th Feb 2015 02:13
AGK still has then NOT command. So in your case:



Will not print the line since 'value' is <> 0.

Allowing for the ! comparator was convenient but not something typically found in BASIC syntax that I know of.
paulrobson
10
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 4th Feb 2015 09:22 Edited at: 4th Feb 2015 09:33
This is slightly unfortunate but this change is consistent both with the documentation, and with the 'style' of AGK2. AGK2 has logical and bitwise operation and the logical ones are longhand AND OR NOT and the bitwise ones are ! and so on. This is especially confusing if you are used to other languages that use ! for logical not.

Generally I'd try to avoid things like (!value) unless value is a boolean (in AGK2 these are 0 and 1).

It shouldn't be hard to retrofit because I think ! is only used for that (?), e.g. no != except in comments or strings.

Login to post a reply

Server time is: 2024-11-25 16:47:21
Your offset time is: 2024-11-25 16:47:21