Author Topic: Messing around with Timers  (Read 112 times)

OnTheCuttingEdge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2381
  • Thank You.
    • View Profile
    • #UltraHal IRC Chat Room
Messing around with Timers
« on: September 09, 2017, 03:31:47 am »
Was just writing some code for a code timer, enjoy!

Code: [Select]
'Rem Type=Plugin
'Rem Name=Timer
'Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
'Rem Host=Assistant

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "This is a delay timer of a few seconds only. to be used for plugin sleep, Script code: 'Sleep' Like If Sleep = 5 Then do something. or for entertainment by saying: Go to sleep."
    lblPlugin(0).Move 120, 10, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
End Sub

Rem PLUGIN: PLUGINAREA1
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.

'THIS TIMER IS MENT FOR PLUGIN SCRIPTS THAT REQUIRE A SLEEP FUNCTION
'OR FOR EDUCATIONAL EXPERIENCE.
HalBrain.ReadOnlyMode = True
TimeResponse = UserSentence
If InStr(1, TimeResponse, " GO TO SLEEP ", vbTextCompare) > 0 Then
T_Minus_Start = Time()
For i = 1 To 800000 '2 seconds   
T_Minus_End = Time()
Sleep = DateDiff("s", T_Minus_Start, T_Minus_End)
If Sleep = 2 Then Exit For   
Next
GetResponse = "I had " & Sleep & " seconds of sleep. "
Exit Function
End If
HalBrain.ReadOnlyMode = False

Just say: go to sleep.

educational purposes.
It is sufficient I guess.

Jerry 8)
Plug =N= Play HAL v7.0 coming soon. There's nothing better than Plug =N= Play!

lightspeed

  • Hero Member
  • *****
  • Posts: 6077
    • View Profile
Re: Messing around with Timers
« Reply #1 on: September 11, 2017, 04:14:47 pm »
If hal snores, i'm going to be mad !! lol just kidding yah !!  :) ;)