Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sleep command in compiler no warning
#4
A *lot* of commands are like this -- EVEN ONES YOU WRITE YOURSELF!!  Wink

Code: (Select All)
Print foo(0.1)
Print foo(0.9)


Function foo& (example As Long)
    foo = example
End Function

There's no warning here that we're passing single values to a long variable, and no error either.  BASIC, all the way from back in the days of GW BASIC, simply rolls with what you send it and doesn't issue a strict "type mismatch" error or anything.  When it's looking for an integer type, and you send it a single type, then it converts to the closest integer value as illustrated above.  

If you look at the wiki for our documentation on SLEEP, you'll find this:  https://qb64phoenix.com/qb64wiki/index.php/SLEEP

Quote:Seconds are an optional INTEGER value. If there is no parameter, then it waits for a keypress.

First comment under the info tells you in big bold letters that this is going to be an integer value. By using 0.1 for SLEEP, it's going to behave *exactly* as any other SUB/FUNCTION with an INTEGER-type parameter -- it's going to round your floats down to the nearest integer value. In this case, that SLEEP .1 gets rounded and basically becomes SLEEP 0...

And SLEEP 0 is the command to "Sleep forever and ever and ever and don't bother counting time; only wake up after the user has pressed some button!"...

...which doesn't sound like that's what you were looking for in this case. Big Grin
Reply


Messages In This Thread
sleep command in compiler no warning - by doppler - 01-10-2025, 04:39 PM
RE: sleep command in compiler no warning - by SMcNeill - 01-11-2025, 02:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fullscreen command glitch 2112 2 499 10-12-2025, 04:33 PM
Last Post: 2112
  _Keyhit is devilishly evil ... here's why (warning) doppler 3 749 09-15-2024, 02:09 PM
Last Post: doppler
  Options menu Compiler Settings TerryRitchie 5 1,301 05-06-2024, 02:17 PM
Last Post: TerryRitchie
  COMMAND$ and wildcards on files zaadstra 18 3,276 01-19-2023, 07:31 PM
Last Post: zaadstra
  Sound Command johnno56 13 2,327 12-23-2022, 09:31 PM
Last Post: mnrvovrfc

Forum Jump:


Users browsing this thread: 1 Guest(s)