Boolean(GetAsyncKeyState(VK_NUMPAD8)) is incorrect. It would work if you cast to WINBOOL, but thats not how GetAsyncKeyState is meant to be used.
The correct way is:
(GetAsyncKeyState(VK_NUMPAD8) and $8000) <> 0
This checks the high bit which indicates if the key is currently down.
Thanks, I get it, but it used to work.Yeap, the typing was loose, it is strict now. In other words, the was allowed typecast was wrong.
Thanks, I get it, but it used to work.Yeap, the typing was loose, it is strict now. In other words, the was allowed typecast was wrong.
Thanks, I get it, but it used to work.
Thanks, I get it, but it used to work.
No, it did not.
It did just accidentally behave as if it worked.
There is a difference between:
- "works" which means the code is correct.
- exposes the expected behaviour (in a very specific case)
The 2nd looks exactly like it works. Even though the code is not correct. But by chance the generated code still deals with all value, the way its desired. Just the important difference is "by chance" => "by random accident". That should not be called "works". (if you want to describe it is correct).
"By chance", is like rolling a dice, and once you got 3 times the "6 dots" that you wanted, you say "I can always at will roll a 6", it has worked.
"boolean(somevalue)" has always only been guaranteed for somevalue being either exactly 0 or 1.
For any other value, that behaviour has always been undefined.
In your case this undefined may have just been the way you wanted it. But it was not guaranteed to stay.
The cause was that a Pascal Boolean is either 0 (false) or 1 (true)
The compiler previously wrongly assumed it could interpret true as any other value than 0.
To mitigate that, indeed use the <> operator, which will translate to Pascal false or true. (0/1)