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 / Logical NOT - not working? Surely NOT?

Author
Message
mdgunn
10
Years of Service
User Offline
Joined: 31st Mar 2014
Location:
Posted: 31st Mar 2014 10:16
NOT does not (no pun intended) seem to work but <> does.

Seems like this would be such a biggy that it must just be me being silly.

Why does my code below tell me 2 numbers I have set to be the same are not the same, if I use NOT? I suppose the answer might just be to use <> and avoid NOT....but, have I just been staring at the screen too long and I'm not seeing the REALLY OBVIOUS ERROR here?


Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Mar 2014 13:04
before some days someone also wrote this "NOT" issue for paul.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
mdgunn
10
Years of Service
User Offline
Joined: 31st Mar 2014
Location:
Posted: 31st Mar 2014 13:50
Thanks, yes I later saw it mentioned in a posting about a recent release, but my post was with moderators (as I'm new user) so I couldn't edit it.

Seems to be a real issue then. I thought it was more likely I was being silly/crazy from staring at the screen too long than 'NOT' being broken. At least I can work round it and use <> instead.

Thanks
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 31st Mar 2014 15:19
Have Paul acknowledged this bug with a reply? Since he is currently working on the compiler for v2 the timing would be perfect.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Mar 2014 15:57
hmm, i wish all v1 users get a good offer to update to v2
and we have only one working version for all - later.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 31st Mar 2014 17:33
Backing v2 is still very cheap and I see no reason not to do it. V2 is already better than v1. The final price for v2 is announced as $149.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 31st Mar 2014 17:46
This is because Basic makes no distinction between test and assignment.

dice1 = dice2 has high precedence, (), so it puts the value of dice2 into dice 1.

<> is actually a logical comparison rather than assignment, so it works.

It's a serious flaw in the Basic language, which is why it's better to use C++ or Pascal! Actually, C is a bit daft here, because a = b or a == b are both valid, but the results may be unintended.

You don't have this problem in Pascal, because a = b is a test returning true or false and a := b is an assignment. The compiler will not let you make this potentially fatal error.

-- Jim - When is there going to be a release?
mdgunn
10
Years of Service
User Offline
Joined: 31st Mar 2014
Location:
Posted: 31st Mar 2014 17:49
I think there was not a reply from Paul about this but and I did not see it in the official bug list (after a quick look) so I will see if I can add it. I thought it was probably just me being silly but seems to be a real bug.

I suppose there is a chance that fixes that are bugs and not features might(should?) be rolled back into v1 so there may be hope for non V2 owners. Given the low cost of AppGameKit (compared to some other products) development/maintenance time would have to be carefully rationed.
mdgunn
10
Years of Service
User Offline
Joined: 31st Mar 2014
Location:
Posted: 31st Mar 2014 18:22
Quote: "JimHawkins - This is because Basic makes no distinction between test and assignment."


I did wonder if this might be part of the problem at the time. I did a bit more testing and even when you use other logical operators such as greater the NOT bit just is never firing.



I thought maybe I was being crazy and just not getting BASIC (it's been a while - more used to C#) but I think this is a bug here so I'll see if I can log it on the official list.

Thanks for the feedback.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Mar 2014 18:33
@JimHawkins
the basic i know did not make a assignment between if then or as parameter, or inside brackets.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 31st Mar 2014 20:02
Oh yes it did, Markus!

-- Jim - When is there going to be a release?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Mar 2014 20:09 Edited at: 31st Mar 2014 20:10
@JimHawkins
hmm, what is the name of this basic that make a assignment in (a=b)?
the old visual basic 6 do not do it.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 31st Mar 2014 20:50 Edited at: 1st Apr 2014 06:05
The = symbol is contextual in BASIC, it's both assignment and equality test.

Mika
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 31st Mar 2014 21:29
Hi everybody,

In the V108, the following user function works very well to implement the "NOT" statement as it does not work.
There is no issue at all at compilation time, even if the 'not' name is used:

function not(value as integer)
result as integer

if (value = 0)
result = 1
else
result = 0
endif

endfunction result


Best regards

Michel
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Apr 2014 04:08
It is not a good idea to create a function with the same name as a reserved word. I am actually very surprised that you got away with it.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Mika
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location: South of France
Posted: 1st Apr 2014 12:14 Edited at: 1st Apr 2014 12:18
Hi ancien Lady,

It is just a work around to implement the NOT statement that is not currently supported by the V108. Of course, the example I gave only supports integer based boolean operation, bit support is not implemented.

Howhever, the advantage I can see is to allow the use of NOT operand until the bug is corrected. When it will be, in the next Tier 1 AppGameKit version I hope, and in order to use the fixed NOT statement, you would have to remove the user not() function and replace only the call to this by regular not statement in the code.
This would allow in advance development taking in account the next defect fixes.

Regarding the fact that compilation is ok and execution also is maybe linked to the fact that, in a case a statement (AND, OR, XOR, ...) is used and, in other one, a function is used.
The signatures are certainly different as function signature would correspond to the function name, the input parameter types and the return type.
I believe it is the reason it actually works as:
- signature(not) <> signature(integer not(integer)).

Below the modified code I took back from previous message in this thread with 'not' and 'and' user defined functions (i.e. I added the and user defined funtion to ensure that an already working statement can be, let say, "overrided" by an user defined function and it is the case).





Best regards

Michel

Michel

Login to post a reply

Server time is: 2024-05-05 01:32:36
Your offset time is: 2024-05-05 01:32:36