fb:porticula NoPaste
@DonStevone: Callback
Uploader: | Sebastian |
Datum/Zeit: | 30.08.2011 12:39:46 |
'zu http://www.freebasic-portal.de/porticula/ich-versteh-die-callbacks-noch-nicht-ganz-1313.html
'Ungetestet, aber kein Compilezeitfehler
#Define Timer_Loop 0
#Define Timer_NoLoop 1
Declare Sub TimerEvent(ByVal TimerName as String)
Type TimerUDT
Dim as Sub(byval x as string) CB
Dim as Integer StartTime
Dim as Integer RunTime
Dim as String TName
Dim as Byte Mode
Dim as Byte Aktive
Declare Constructor(ByVal TimerName as String, ByVal TimeToRun as Integer, ByVal Modus as Byte, ByVal Callback as Sub(byval x as string))
Declare Sub Update()
End Type
'###############################################################################
Constructor TimerUDT(ByVal TimerName as String, ByVal TimeToRun as Integer, ByVal Modus as Byte, ByVal Callback as Sub(byval x as string))
TName = TimerName
RunTime = TimeToRun
Mode = Modus
CB = Callback
StartTime = Timer
Aktive = 1
End Constructor
'###############################################################################
Sub TimerUDT.Update()
If Aktive = 1 and Timer - StartTime >= RunTime then
If Mode = 0 then
CB(TName)
ElseIf Mode = 1 then
Aktive = 0
CB(TName)
Endif
Endif
End Sub