A way to pause for milliseconds?

Started by twgonder, July 04, 2021, 01:21:34

Previous topic - Next topic

twgonder

Pause seems to work with seconds, but there are instances where I would like to pause for milliseconds (for example to debug output, but a second is too long.
Maybe a decimal?
pause 1.1 = 1 second and one millisecond
pause 0.10 = 10 milliseconds
pause 0.999 = 1 millisecond less that one second

Or is there another way that won't pound processing sand?

steve_ancell

#1
I'm not sure about SmallBASIC but AGK2 has a Sleep command which would be used as Sleep(millisecs).

If the Sleep command didn't exist then I would do something like this:

function _WaitTime(ms as integer)
    local timeStamp as integer
    timeStamp = GetMilliseconds()
   
    while GetMilliseconds() < timeStamp + ms
        // Wait until millisecs is more than first recorded time plus ms

    endwhile
   
endfunction


jsalai

#3
Quote from: twgonder on July 04, 2021, 01:21:34
Pause seems to work with seconds, but there are instances where I would like to pause for milliseconds (for example to debug output, but a second is too long.
Maybe a decimal?
pause 1.1 = 1 second and one millisecond
pause 0.10 = 10 milliseconds
pause 0.999 = 1 millisecond less that one second

Or is there another way that won't pound processing sand?

SmallBASIC is neither small nor basic. So it is really worth to spend a half an hour to step thru the references.

https://smallbasic.github.io/pages/reference.html

sometimes more, sometimes less informative, but at least giving hints...
I won't belong to any organization that would have people like me as members.
[Groucho Marx]

bplus

1 person likes this

twgonder

#5
Quote from: jsalai on July 04, 2021, 08:56:24

SmallBASIC is neither small nor basic. So it is really worth to spend a half an hour to step thru the references.

https://smallbasic.github.io/pages/reference.html

sometimes more, sometimes less informative, but at least giving hints...

I've been doing that, for much more than a half hour. There are a lot of errors, bad descriptions and complicated code without starting with a simple explanation. But yes, there are some hints and that's about it most of the time.

For example, here is the what is shown for the syntax of the DIM statement:
DIM var([lower TO] upper [, ...]) [, ...]
Is the right parenthesis in the wrong place or is there some unexplained option for the DIM statement?
Maybe it is trying to say another array variable after the comma?
Is an array limited to just two or three dimensions (if the right parenthesis is indeed in the wrong location)?

how about: DIM var1, var2(n), var3([l1 TO] n1), var4(5,6,7,8,n9)

twgonder

#6
Quote from: blinkok on July 04, 2021, 08:17:25
Program.delay(1000) will wait 1 second
Okay, I tried that as a line. Error: Not a function
So is this an actual command? Or a function in a library somewhere? Or a routine I have to write?

jsalai

Quote from: twgonder on July 05, 2021, 17:09:56
Quote from: blinkok on July 04, 2021, 08:17:25
Program.delay(1000) will wait 1 second
Okay, I tried that as a line. Error: Not a function
So is this an actual command? Or a function in a library somewhere? Or a routine I have to write?

delay 1000

I won't belong to any organization that would have people like me as members.
[Groucho Marx]

twgonder

Quote from: jsalai on July 05, 2021, 20:39:34
Quote from: twgonder on July 05, 2021, 17:09:56
Quote from: blinkok on July 04, 2021, 08:17:25
Program.delay(1000) will wait 1 second
Okay, I tried that as a line. Error: Not a function
So is this an actual command? Or a function in a library somewhere? Or a routine I have to write?

delay 1000

Excellent, and now I can read the online help about it!