Sleep command issue

Linux specific questions.
fxm
Posts: 8060
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Sleep command issue

Postby fxm » Apr 11, 2018 8:45

What about 'Sleep' during a specified time on Linux text console

On a Linux text console, can you check if the following program is rightly working?
Waiting for one keypress to print 'one', then automatic delay of two seconds between each next printing (without pressing any key):

Code: Select all

sleep
?"one"
sleep 2000
?"two"
sleep 2000
?"three"
sleep 2000
?"four"
sleep
tom_dehn
Posts: 4
Joined: Apr 05, 2017 13:50

Re: Sleep command issue

Postby tom_dehn » Apr 11, 2018 8:46

Hallo,

it`s almost all fine with the macros, but they sleep "forever".
Any idea to do a macro "timeout" like the DOC says:

"Waits until a specified time has elapsed, or a key is pressed.
Syntax
Declare Sub Sleep ( ByVal amount As Long = -1 )
Declare Function Sleep ( ByVal amount As Long , ByVal keyflag As Long ) As Long"

(copied from CHM, "mk:@MSITStore:C:\PRG\FBC\HelpFiles\FB-manual-1.05.0.chm::/KeyPgSleep.html")

Just have a look at my pause(); don´t bother about performance: It is a _sleep_ :)

TD
lizard
Posts: 404
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Sleep command issue

Postby lizard » Apr 11, 2018 9:09

fxm wrote:On a Linux text console, can you check if the following program is rightly working?

No. It waits for a keypress, then displays the rest without any delay.

Code: Select all

one
two
three
four
fxm
Posts: 8060
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Sleep command issue

Postby fxm » Apr 11, 2018 9:35

More general workaround macro using a variadic syntax:

Code: Select all

#macro _sleep( args... )
    While InKey() <> "" : Wend
    Sleep args
#endmacro

_sleep( )
?"one"
_sleep( 2000 )
?"two"
_sleep( 2000 , 0 )
?"three"
_sleep( 2000 )
?"four"
_sleep( 10000, 1 )
lizard
Posts: 404
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Sleep command issue

Postby lizard » Apr 11, 2018 10:48

Funny, that works, but without delay, Only after four there is 10 seconds delay before end.
fxm
Posts: 8060
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Sleep command issue

Postby fxm » Apr 11, 2018 11:36

Having no Linux PC, I can not go further in the investigation.
lizard
Posts: 404
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Sleep command issue

Postby lizard » Apr 11, 2018 12:58

You could use a live dvd.
lizard
Posts: 404
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Sleep command issue

Postby lizard » Apr 11, 2018 13:08

I have booted in win 10 recently and what i never expected all the years, win appears slow and akward now. I will stay with Mint.
sancho3
Posts: 257
Joined: Sep 30, 2017 3:22

Re: Sleep command issue

Postby sancho3 » Apr 12, 2018 2:40

@FXM:
Your variadic macro works perfectly on Ubuntu.
All the timings worked.
I tested keypresses to bypass the sleep and they all worked as they should have. It ignored the keypress on the last sleep 10000, 1.
I will post a bug report tonight, if someone hasn't already done so.
Bug reported
coderJeff
Site Admin
Posts: 2598
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Sleep command issue

Postby coderJeff » May 21, 2018 18:05

Proposed fix @ https://github.com/freebasic/fbc/pull/84

Current problem is that fb linux rtlib was using "is there a key to be read?" as the test for "has a key been hit?"

I changed unix keyboard handler so should behave same as windows console. In this example code, if you press a key during the 5 sec delay at the start the, first SLEEP is passed, but not the second SLEEP. Like in windows.

Code: Select all

dim t as double = timer
print "wait 5 secs"
while( timer - t ) < 5
wend
print "1"
sleep
print "2"
sleep
print "3"
sleep
sancho3
Posts: 257
Joined: Sep 30, 2017 3:22

Re: Sleep command issue

Postby sancho3 » May 22, 2018 5:56

Very nice. Thank you for working on this and fixing it.

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest