ElapsedMilliseconds( )
Re: ElapsedMilliseconds( )
What you want to tell me, I can't understand. did you run my code on windows?
Re: ElapsedMilliseconds( )
The DoubleClickTime() function returns the system setting.
Not the last pressed time. But I think that is clear.
Under windows, it returns 500ms, which is correct.
Not the last pressed time. But I think that is clear.
Under windows, it returns 500ms, which is correct.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: ElapsedMilliseconds( )
This is understandable to this function, I have no questions, why are you sticking to it? I have a question for another function, is it really hard to understand?
Code: Select all
Procedure ClickCount( )
Static ClickTime.q, ClickCount
Protected DoubleClickTime = 500
If ClickTime And
DoubleClickTime > ( ElapsedMilliseconds( ) - ClickTime )
ClickCount + 1
Else
ClickCount = 1
EndIf
ClickTime = ElapsedMilliseconds( )
ProcedureReturn ClickCount
EndProcedure
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
on the windows returns 1;1;2;3
this is because the first time ElapsedMilliseconds( ) returns 0
Re: ElapsedMilliseconds( )
...
Last edited by mk-soft on Mon Feb 06, 2023 7:21 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: ElapsedMilliseconds( )
Window and macOS start time is minimal differentmestnyi wrote: ↑Mon Feb 06, 2023 6:46 pmThis is understandable to this function, I have no questions, why are you sticking to it? I have a question for another function, is it really hard to understand?on the Mac os returns 1;2;3;4Code: Select all
on the windows returns 1;1;2;3
this is because the first time ElapsedMilliseconds( ) returns 0
Code: Select all
Procedure ClickCount( )
Static ClickTime.q, ClickCount
Protected DoubleClickTime = 500
If ClickTime And
DoubleClickTime > ( ElapsedMilliseconds( ) - ClickTime )
ClickCount + 1
Else
ClickCount = 1
EndIf
ClickTime = ElapsedMilliseconds( )
ProcedureReturn ClickCount
EndProcedure
;Init
ElapsedMilliseconds()
Delay(100)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: ElapsedMilliseconds( )
Maybe that way you will understand what I am trying to convey to you.
Code: Select all
Procedure ClickCount( )
Static ClickTime.q, ClickCount
Protected DoubleClickTime = 500
Debug " time "+ Str((ElapsedMilliseconds( )-ClickTime) + Bool( #PB_Compiler_OS ) * 492)
If DoubleClickTime > ( ElapsedMilliseconds( ) - ClickTime ) + Bool( #PB_Compiler_OS ) * 492
ClickCount + 1
Else
ClickCount = 1
EndIf
ClickTime = ElapsedMilliseconds( )
ProcedureReturn ClickCount
EndProcedure
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
Delay(498)
Debug ClickCount( )
; windows
; time 0
; 1
; time 9
; 2
; time 9
; 3
; time 15
; 4
; mac os
; time 695
; 1
; time 498
; 2
; time 498
; 3
; time 499
; 4
Re: ElapsedMilliseconds( )
There seems to be a delay in macOS when ElapseMilliseconds is called for the first time. Something from 16 to 1000 ms.
With windows this is always zero.
Thus, the difference calculation is not correct on the first run.
Therefore, one must (as before) save the time on the first run.
Update
With windows this is always zero.
Thus, the difference calculation is not correct on the first run.
Therefore, one must (as before) save the time on the first run.
Update
Code: Select all
Procedure ClickCount( )
Static ClickTime.q, LastClickTime, ClickCount
Protected DoubleClickTime = 500
If Not LastClickTime
LastClickTime = ElapsedMilliseconds()
EndIf
ClickTime = ElapsedMilliseconds()
Debug " time " + ClickTime
If (ClickTime - LastClickTime) < DoubleClickTime
ClickCount + 1
Else
ClickCount = 1
EndIf
LastClickTime = ClickTime
ProcedureReturn ClickCount
EndProcedure
Debug ClickCount( )
Delay(496)
Debug ClickCount( )
Delay(496)
Debug ClickCount( )
Delay(496)
Debug ClickCount( )
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: ElapsedMilliseconds( )
Code: Select all
StartTime.q = ElapsedMilliseconds() ; Get the actual value
Delay(1000) ; Wait 1000 milliseconds
Debug ElapsedMilliseconds() - StartTime ; Displayed value should be about 1000 milliseconds
That's where the error is.
Re: ElapsedMilliseconds( )
Can't be ...
Your PB or OS is broken. It must come out 1000 ms.
Your PB or OS is broken. It must come out 1000 ms.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: ElapsedMilliseconds( )
VirtualBox is likely the problem. My own app has issues with VirtualBox, too, but it runs fine on any real PC that I test it on.
Re: ElapsedMilliseconds( )
But what about the elapsedMilliseconds() under the hood?
Or how to get it using the API?
Or how to get it using the API?
Re: ElapsedMilliseconds( )
You never should call ElapsedMilliseconds() any times.
-> Synchroneous system = one time
-> Asynchroneous system (clock analyzing) = any time
Use Global Lap = ElapsedMilliseconds() in your main procedure.
Even in a normal way, this is bad, because you clock measurement depends of the ClickCount() call frequency, but not, of the clicking frequency.
That is the reason you should add a sync timer.
Else, there is this :
-> Synchroneous system = one time
-> Asynchroneous system (clock analyzing) = any time
Use Global Lap = ElapsedMilliseconds() in your main procedure.
Code: Select all
Procedure ClickCount( )
Static ClickTime.q
Static ClickCount.i
Protected DoubleClickTime = 500
Protected Lap = ElapsedMilliseconds()
If ClickTime And
DoubleClickTime > ( Lap - ClickTime )
ClickCount + 1
Else
ClickCount = 1
EndIf
ClickTime = Lap
ProcedureReturn ClickCount
EndProcedure
Code: Select all
Procedure ClickCount(Reset = 0)
Protected Lap.q = ElapsedMilliseconds()
Static initialTime.q
Static finalTime.q
Protected deltaTime.q
Static clickCount.i
initialTime = finalTime
deltaTime = finalTime - initialTime
If deltaTime > 30 And deltaTime < 300
clickCount + 1
EndIf
If Reset
clickCount = 0
EndIf
ProcedureReturn clickCount
EndProcedure
Else, there is this :
Code: Select all
If WindowEvent() = #PB_Event_LeftDoubleClick
Debug "double click"
EndIf
Re: ElapsedMilliseconds( )
Just for the record, the example code works perfectly on my system which runs under VirtualBox inside a Linux server that I connect to through RDP. I don't normally experience any problems with VirtualBox, at least not that I'm aware of I see precisely 1,000ms from the below.
Code: Select all
StartTime.q = ElapsedMilliseconds() ; Get the actual value
Delay(1000) ; Wait 1000 milliseconds
Debug ElapsedMilliseconds() - StartTime ; Displayed value should be about 1000 milliseconds
Re: ElapsedMilliseconds( )
@Oso
Delay(1 to 16) = waits 16ms, 17ms or more...
Delay(17) = waits 32ms, 33ms, 34ms or more...
etc...
And ElapsedMilliseconds() gives this :
0, 0, 0, 0
16, 16, 16, 16, 16,
33, 33, 33, 33, 33,
48, 48, 48,
49, 49, 49, 49, 49,
50,
65, 65, 65, 65, etc...
XP OS doesn't allow the processus from having an accurate duration :mestny wrote:I have Windows XP Virtualbox[...]
Delay(1 to 16) = waits 16ms, 17ms or more...
Delay(17) = waits 32ms, 33ms, 34ms or more...
etc...
And ElapsedMilliseconds() gives this :
0, 0, 0, 0
16, 16, 16, 16, 16,
33, 33, 33, 33, 33,
48, 48, 48,
49, 49, 49, 49, 49,
50,
65, 65, 65, 65, etc...