Ooops
October 20, 2021, 04:27:03

Author Topic: A way to pause for milliseconds?  (Read 502 times)

Offline twgonder

  • Jr. Member
  • **
  • Posts: 29
A way to pause for milliseconds?
« 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?

Offline steve_ancell

  • Jr. Member
  • **
  • Posts: 33
Re: A way to pause for milliseconds?
« Reply #1 on: July 04, 2021, 04:42:28 »
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
« Last Edit: July 04, 2021, 05:00:42 by steve_ancell »

Offline blinkok

  • Sr. Member
  • ****
  • Posts: 380

Offline jsalai

  • Jr. Member
  • **
  • Posts: 41
Re: A way to pause for milliseconds?
« Reply #3 on: July 04, 2021, 08:56:24 »
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...
« Last Edit: July 04, 2021, 08:58:39 by jsalai »
I won't belong to any organization that would have me as a member.
[Groucho Marx]

Offline bplus

  • Full Member
  • ***
  • Posts: 228
Re: A way to pause for milliseconds?
« Reply #4 on: July 04, 2021, 11:28:03 »
Check out Delay for SmallBASIC.

Offline twgonder

  • Jr. Member
  • **
  • Posts: 29
Re: A way to pause for milliseconds?
« Reply #5 on: July 05, 2021, 17:05:14 »

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)
« Last Edit: July 06, 2021, 15:00:20 by twgonder »

Offline twgonder

  • Jr. Member
  • **
  • Posts: 29
Re: A way to pause for milliseconds?
« Reply #6 on: July 05, 2021, 17:09:56 »
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?
« Last Edit: July 05, 2021, 17:32:53 by twgonder »

Offline jsalai

  • Jr. Member
  • **
  • Posts: 41
Re: A way to pause for milliseconds?
« Reply #7 on: July 05, 2021, 20:39:34 »
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 me as a member.
[Groucho Marx]

Offline twgonder

  • Jr. Member
  • **
  • Posts: 29
Re: A way to pause for milliseconds?
« Reply #8 on: July 06, 2021, 15:03:33 »
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!

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal