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 / T1 1088 - Not NOT Working !

Author
Message
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 29th Jan 2013 19:53
Hi, No sure if this has already been reported as a bug.

In 1085 the following code works as expected but in 1088 it seems as if Not is no longer working correctly.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Jan 2013 20:08
Try this: If Not (-1 = a)

It is probable that the parsing of your statement isn't working the way you expect.

In C++ (and this may apply to how the AppGameKit compiler parses), 'Not' has precedence over equality ('==' in C++ and '=' in AppGameKit Basic if statement). So your statement might be being evaluated as "(Not a) == -1".

And, just for safeness, swapping the sides on the equality test doesn't hurt.

I had a strange case in another language where the order of a constant value (like your -1) and a variable comparison worked in way and not the other.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 29th Jan 2013 20:18
No still does not work correctly.

As I said in 1085 this works correctly.

a > -1 fixes it for me at the moment. Maybe someone else can confirm it's as a bug !

thanks Stuart
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Jan 2013 20:39
You could also do "a <> -1". This is more of the proper reinterpretation of your original code.

This is not a bug so much as an issue of how things get parsed. The precedence of different operators (Not, And, Or, ==, <>, etc.) needs to be known if you want to write logical expressions without parenthesis.

And there isn't any documentation about the operator precedence that AppGameKit Basic uses. We cannot assume the same as C++ (MS Visual Basic does not use the same precedence as Ansi C++, for instance).

Further googling found an FE post (from the closed forum) that describes AppGameKit Basic as using BBC Basic (?). And it puts unary+- and Not as higher precedence than comparisons (<,>,<>,==,>=,<=). So your original statement was being parsed the way I suspected as: (Not a) = -1

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-06 17:18:32
Your offset time is: 2024-05-06 17:18:32