Author Topic: NOT an old bug...  (Read 2547 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
NOT an old bug...
« on: August 10, 2019, 02:08:06 pm »
The IDE needs some work with finding and error trapping NOT glitches.  You guys would never believe how long it took me to try and decipher this little jewel out of my program:

Code: QB64: [Select]
  1.             IF _MOUSEBUTTON(1) AND NOT old mouse THEN 'it's a click
  2.                 Xclick = (_MOUSEX - 45) \ 110
  3.             END IF

Needless to say, I've got a variable named oldmouse in my program, and in the rush of coding, I never noticed that I added a space in the name.  The IDE doesn't complain over the glitch either, but it does give us a PITA C++ Compilation failed message:

Quote
.\\temp\\main.txt:321:65: error: invalid operands of types 'int' and 'int*' to binary 'operator*'
 if (((func__mousebutton( 1 ,NULL,0))&(~(*_SUB_PLAYGAME_LONG_OLD)*_SUB_PLAYGAME_LONG_MOUSE))||new_error){
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.

Got to admit, that wasn't exactly the world's most useful message for me, since I'm only a C-hack at best....



The IDE needs a little additional error checking to try and catch these glitches before it compiles them.  Other things like just PRINT NOT old mouse produce the same effect, so it's probably an issue with parsing NOT itself which needs looking into.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: NOT an old bug...
« Reply #1 on: August 10, 2019, 02:19:43 pm »
The IDE does have OPTION _EXPLICIT and I am pretty sure OPTION _EXPLICIT would likely catch errors like that.

Man the troubles I imagine it has saved me from since I started using it... specially as my eyes are getting bad.

But NOT logic does offer it's own unique brand of trouble. I've started being explicit x = 0 or  x <> 0 and avoid NOT.

Instead of WHILE NOT EOF(1), it is WHILE EOF(1) = 0