QB64 Phoenix Edition
Error in Wiki _limit page? - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: Official Links (https://staging.qb64phoenix.com/forumdisplay.php?fid=16)
+--- Forum: QB64 Phoenix Edition Wiki and Repo (https://staging.qb64phoenix.com/forumdisplay.php?fid=41)
+---- Forum: Wiki Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=25)
+---- Thread: Error in Wiki _limit page? (/showthread.php?tid=1618)



Error in Wiki _limit page? - PhilOfPerth - 04-13-2023

In the Wiki, on the _Limit page, point number 5 says we should not try to use _limit for less than once every 60 seconds.
I think this should be 60 times per second, unless I'm reading it incorrectly.  Huh


RE: Error in Wiki _limit page? - SMcNeill - 04-13-2023

It's once per 60 seconds.  

DO
   _LIMIT (1 / 60)
LOOP

^ Like the above.

Let me explain what it's doing here.

LIMIT 60 -- this says to let the loop run no more than 60 times per second.
LIMIT 30 -- 30 times per second max loop.
LIMIT 2 -- 2 times per second max loop.
LIMIT 1 -- 1 time per second max loop.
LIMIT 1 / 2 -- 1/2 time per second... or 1 time per 2 seconds, max loop speed.
LIMIT 1 / 3 -- 1/3 time per second... or 1 time per 3 seconds, max loop speed.

So a LIMIT 1 / 60 is a max speed of basically 1 loop per minute. (1 loop per 60 seconds.)

Anything longer than that, the fractions get so small, the math involved gets goofy.  If you need more than a 1/60 limit, then you need to get creative with how you accomplish it.  Wink

DO
     FOR I = 1 TO 10
         _LIMIT 1 / 60
    NEXT
    'Do stuff...
LOOP

^ A loop that only processes once every 10 minutes.


RE: Error in Wiki _limit page? - PhilOfPerth - 04-13-2023

Sorry Steve, I just don't understand the wording of rule #5 in the Wiki.

First it says "The _LIMIT statement sets the loop repeat rate of a program to so many per second"
and then in rule #5, "Do not use it to limit a loop to less than once every 60 seconds(.0167)"

_Limit 30, as you say, limits to no more than 30 times per second (or once every 1/30 second), which is much less than once every 60 seconds.

The function works, just as you described, but rule #5  in the Wiki is, I think upside-down, and should be not less than once every 1/60 second.


RE: Error in Wiki _limit page? - RhoSigma - 04-13-2023

That point #5 refers to the amount of loops not the amount of _LIMITs:

"Do not use it to limit a loop to less than once every 60 seconds(.0167)"

should better say:

"Do not use it to limit a loop to run less than once every 60 seconds (i.e. _LIMIT .0167 or _LIMIT 1/60)"

I'll change that wording in the Wiki...