ScriptForge.Timer zerbitzua

Timer zerbitzuak erabiltzaile-scriptak exekutatzeak zenbat denbora behar duen neurtzen du.

A Timer measures durations. It can be:

Iradokizun-ikonoa

Durations are expressed in seconds with a precision of 3 decimal digits (milliseconds). A duration value of 12.345 means 12 seconds and 345 milliseconds


Zerbitzuari deitzea

Before using the Timer service the ScriptForge library needs to be loaded using:


    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
  

The example below creates a Timer object named myTimer and starts it immediately.


    Dim myTimer As Variant
    myTimer = CreateScriptService("Timer", True)
    'The timer starts immediately when the second argument = True, default = False
  

It is recommended to free resources after use:


    Set myTimer = myTimer.Dispose()
  
note

Zerbitzu hau erabat onartuta dago bai Basic bai Python lengoaietan. Adibide guztiak Basic programazio-lengoaian eman dira, baina erraz bihurtu daitezke Python lengoaiara.


Propietateak

Izena

Irakurtzeko soilik

Mota

Deskribapena

Duration

Bai

Double

The actual running time elapsed since start or between start and stop (does not consider suspended time)

IsStarted

Bai

Boolean

True when timer is started or suspended

IsSuspended

Bai

Boolean

True when timer is started and suspended

SuspendDuration

Bai

Double

The actual time elapsed while suspended since start or between start and stop

TotalDuration

Bai

Double

The actual time elapsed since start or between start and stop (including suspensions and running time)


Iradokizun-ikonoa

Note that the TotalDuration property is equivalent to summing the Duration and SuspendDuration properties.


Metodoak

All methods do not require arguments and return a Boolean value.

If the returned value is False, then nothing happened.

Izena

Deskribapena

Itzulitako balioa

Continue

Resumes the Timer if it has been suspended

False if the timer is not suspended

Restart

Terminates the Timer and discards its current property values, restarting as a new clean Timer

False (faltsua) kronometroa inaktibo badago

Start

Kronometro garbi berria abiarazten du

False (faltsua) kronometroa dagoeneko hasi bada

Suspend

Abian dagoen kronometro bat eteten du

False (faltsua) kronometroa hasi ez bada edo dagoeneko eten bada

Terminate

Abian dagoen kronometro bat gelditzen du

False (faltsua) kronometroa ez bada hasi edo eten


Adibidea:


      myTimer.Start()
      Wait 500
      myTimer.Suspend()
      'The time elapsed while the Dialog box is open will be counted as suspended time
      MsgBox myTimer.Duration & " " & myTimer.SuspendDuration & " " & myTimer.TotalDuration
      myTimer.Continue()
      Wait 500
      'The time elapsed while the Dialog box is open will be counted as running time
      MsgBox myTimer.Duration & " " & myTimer.SuspendDuration & " " & myTimer.TotalDuration
      myTimer.Terminate()
      'Shows the final time measurements
      MsgBox myTimer.Duration & " " & myTimer.SuspendDuration & " " & myTimer.TotalDuration
    
note

If you call the Terminate method, subsequent calls for the Continue method will not resume time measurement. Similarly, after a Timer has been terminated, calling the Start method will restart it as if it were a clean new Timer.


Kronometro anitzekin lan egitea

It is possible to instantiate multiple Timer services in parallel, which gives flexibility in measuring time in different parts of the code.

The following example illustrates how to create two Timer objects and start them separately.


    Dim myTimerA as Variant, myTimerB as Variant
    myTimerA = CreateScriptService("Timer")
    myTimerB = CreateScriptService("Timer")
    'Starts myTimerA
    myTimerA.Start()
    Wait 1000 'Wait 1 second (1,000 milliseconds)
    MsgBox myTimerA.Duration & " " & myTimerB.Duration
    'Starts myTimerB
    myTimerB.Start()
    Wait 1000
    MsgBox myTimerA.Duration & " " & myTimerB.Duration
    'Amaitu kronometro biak
    myTimerA.Terminate()
    myTimerB.Terminate()
  
warning

Aurrizki gisa azpimarra bat ("_") duten ScriptForge Basic errutina edo identifikatzaile guztiak barneko erabilerarako erreserbatuta daude. Ez daude Basic makroetan erabiltzeko pentsatuta.