Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)
Moderator: Moderators
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-08-18 00:07
Inspired by the code to broadcast a text message on a regular interval, I decided to come up with a quarter hour time chime to let my hub's users know what time it was (at least on my machine, which is important because my reboot messages always are in my time.) This is a VB script for NMDCH.
Code: Select all
' Quarter Hour Chime v 1.0
' by Lightning Man
' from InfoBot by HaArD
' with elements from Shadowtek
Dim sBotName, iMinutes, iStarter, sTime
Sub main()
sBotName = "Chime"
iMinutes = 15 ' This script is designed to run on the quarter hour.
' If you change this you must change all the iStarter calculations below
tmrScriptTimer.interval = 60000
tmrScriptTimer.enabled = True
iStarter = minute(Now) ' This section synchs the timer with the quarter hour
If iStarter = 0 Then tmrScriptTimer.tag = 15
If 0 < iStarter < 16 Then tmrScriptTimer.tag = iStarter
If 15 < iStarter < 31 Then tmrScriptTimer.tag = iStarter - 15
If 30 < iStarter < 46 Then tmrScriptTimer.tag = iStarter - 30
If 45 < iStarter < 60 Then tmrScriptTimer.tag = iStarter - 45
' The two lines below are for debugging purposes and may be deleted if you wish
' colUsers.SendChatToAll CStr(sBotName), "Initialized"
' colUsers.SendChatToAll CStr(sBotName), cLng(tmrScriptTimer.tag)
End Sub
Sub tmrScriptTimer_Timer()
If tmrScriptTimer.tag = "" Then
tmrScriptTimer.tag = "0"
End If
tmrScriptTimer.tag = clng(tmrScriptTimer.tag) + 1
If clng(tmrScriptTimer.tag) => iMinutes Then
tmrScriptTimer.tag = "0"
sTime = FormatDateTime(Time, vbLongTime)
colUsers.SendChatToAll CStr(sBotName), cStr("Bong! It's "+sTime+" US Eastern Time.")
' Change time zone info to that of your local machine.
End If
End Sub
Let me know if you like it or have problems with it.
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-08-18 08:18
Darn it. There is an initialization problem because I don't know the proper syntax to make the evaluation I want on one line. Until I learn it, I believe this will solve the problem.
' Quarter Hour Chime v 1.1
' by Lightning Man
' from InfoBot by HaArD
' with elements from Shadowtek
Dim sBotName, iMinutes, iStarter, sTime
Sub main()
sBotName = "Chime"
iMinutes = 15 ' This script is designed to run on the quarter hour.
' If you change this you must change all the iStarter calculations below
tmrScriptTimer.interval = 60000
tmrScriptTimer.enabled = True
iStarter = minute(Now) ' This section synchs the timer with the quarter hour
If iStarter = 0 Then tmrScriptTimer.tag = 15
If iStarter > 0 Then
If iStarter < 16 Then tmrScriptTimer.tag = iStarter
End If
If iStarter > 15 Then
If iStarter < 31 Then tmrScriptTimer.tag = iStarter - 15
End If
If iStarter > 30 Then
If iStarter < 46 Then tmrScriptTimer.tag = iStarter - 30
End If
If iStarter > 45 Then tmrScriptTimer.tag = iStarter - 45
' The two lines below are for debugging purposes and may be deleted if you wish
' colUsers.SendChatToAll CStr(sBotName), "Initialized"
' colUsers.SendChatToAll CStr(sBotName), cLng(tmrScriptTimer.tag)
End Sub
Sub tmrScriptTimer_Timer()
If tmrScriptTimer.tag = "" Then
tmrScriptTimer.tag = "0"
End If
tmrScriptTimer.tag = clng(tmrScriptTimer.tag) + 1
If clng(tmrScriptTimer.tag) => iMinutes Then
tmrScriptTimer.tag = "0"
sTime = FormatDateTime(Time, vbLongTime)
colUsers.SendChatToAll CStr(sBotName), cStr("Bong! It's "+sTime+" US Eastern Time.")
' Change time zone info to that of your local machine.
End If
End Sub
There has to be a more elegant way to say if iStarter is between two constants than double If statements. Any ideas?
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-08-18 08:19
That should have been a code tag instead of a quote tag and I can't change it myself. Sorry.
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-08-18 09:42
This is
NOT yet tested. Iam going to try it at home later, based on standard vb (which this sometimes doesn't duplicate.)
Code: Select all
' Quarter Hour Chime v 1.2 NOT YET TESTED
' by Lightning Man
' from InfoBot by HaArD
' with elements from Shadowtek
Dim sBotName, iMinutes, iStarter, sTime
Sub main()
sBotName = "Chime"
iMinutes = 15 ' This script is designed to run on the quarter hour.
' If you change this you must change all the iStarter calculations below
tmrScriptTimer.interval = 60000
tmrScriptTimer.enabled = True
iStarter = minute(Now) ' This section synchs the timer with the quarter hour
If iStarter = 0 Then tmrScriptTimer.tag = 15
If iStarter > 0 AndAlso iStarter < 16 Then tmrScriptTimer.tag = iStarter
If iStarter > 15 AndAlso iStarter < 31 Then tmrScriptTimer.tag = iStarter - 15
If iStarter > 30 AndAlso iStarter < 46 Then tmrScriptTimer.tag = iStarter - 30
If iStarter > 45 Then tmrScriptTimer.tag = iStarter - 45
' The two lines below are for debugging purposes and may be deleted if you wish
' colUsers.SendChatToAll CStr(sBotName), "Initialized"
' colUsers.SendChatToAll CStr(sBotName), cLng(tmrScriptTimer.tag)
End Sub
Sub tmrScriptTimer_Timer()
If tmrScriptTimer.tag = "" Then
tmrScriptTimer.tag = "0"
End If
tmrScriptTimer.tag = clng(tmrScriptTimer.tag) + 1
If clng(tmrScriptTimer.tag) => iMinutes Then
tmrScriptTimer.tag = "0"
sTime = FormatDateTime(Time, vbLongTime)
colUsers.SendChatToAll CStr(sBotName), cStr("Bong! It's "+sTime+" US Eastern Time.")
' Change time zone info to that of your local machine.
End If
End Sub
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-08-18 16:37
What is the phrase? Keep it Simple, Sweetheart? Anyway, I learned something: just plain 'And' works fine. Final 1.2 version, guaranteed to work (until I find out it doesn't.)
Code: Select all
' Quarter Hour Chime v 1.2
' by Lightning Man
' from InfoBot by HaArD
' with elements from Shadowtek
Dim sBotName, iMinutes, iStarter, sTime
Sub main()
sBotName = "Chime"
iMinutes = 15 ' This script is designed to run on the quarter hour.
' If you change this you must change all the iStarter calculations below
tmrScriptTimer.interval = 60000
tmrScriptTimer.enabled = True
iStarter = minute(Now) ' This section synchs the timer with the quarter hour
If iStarter = 0 Then tmrScriptTimer.tag = 15
If iStarter > 0 And iStarter < 16 Then tmrScriptTimer.tag = iStarter
If iStarter > 15 And iStarter < 31 Then tmrScriptTimer.tag = iStarter - 15
If iStarter > 30 And iStarter < 46 Then tmrScriptTimer.tag = iStarter - 30
If iStarter > 45 Then tmrScriptTimer.tag = iStarter - 45
' The two lines below are for debugging purposes and may be deleted if you wish
' colUsers.SendChatToAll CStr(sBotName), "Initialized"
' colUsers.SendChatToAll CStr(sBotName), cLng(tmrScriptTimer.tag)
End Sub
Sub tmrScriptTimer_Timer()
If tmrScriptTimer.tag = "" Then
tmrScriptTimer.tag = "0"
End If
tmrScriptTimer.tag = clng(tmrScriptTimer.tag) + 1
If clng(tmrScriptTimer.tag) => iMinutes Then
tmrScriptTimer.tag = "0"
sTime = FormatDateTime(Time, vbLongTime)
colUsers.SendChatToAll CStr(sBotName), cStr("Bong! It's "+sTime+" US Eastern Time.")
' Change time zone info to that of your local machine.
End If
End Sub
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-08-29 22:20
Adds an adjustment to keep it on the quarter hour, preventing drift.
Code: Select all
' Quarter Hour Chime v 1.3
' by Lightning Man
' from InfoBot by HaArD
' with elements from Shadowtek
Dim sBotName, iMinutes, iStarter, sTime
Sub main()
sBotName = "Chime"
iMinutes = 15 ' This script is designed to run on the quarter hour.
' If you change this you must change all the iStarter calculations below
tmrScriptTimer.interval = 60000
tmrScriptTimer.enabled = True
iStarter = minute(Now) ' This section synchs the timer with the quarter hour
If iStarter = 0 Then tmrScriptTimer.tag = 15
If iStarter > 0 And iStarter < 16 Then tmrScriptTimer.tag = iStarter
If iStarter > 15 And iStarter < 31 Then tmrScriptTimer.tag = iStarter - 15
If iStarter > 30 And iStarter < 46 Then tmrScriptTimer.tag = iStarter - 30
If iStarter > 45 Then tmrScriptTimer.tag = iStarter - 45
' The two lines below are for debugging purposes and may be deleted if you wish
' colUsers.SendChatToAll CStr(sBotName), "Initialized"
' colUsers.SendChatToAll CStr(sBotName), cLng(tmrScriptTimer.tag)
End Sub
Sub tmrScriptTimer_Timer()
If tmrScriptTimer.tag = "" Then
tmrScriptTimer.tag = "0"
End If
tmrScriptTimer.tag = clng(tmrScriptTimer.tag) + 1
If clng(tmrScriptTimer.tag) => iMinutes Then
tmrScriptTimer.tag = "0"
sTime = FormatDateTime(Time, vbLongTime)
colUsers.SendChatToAll CStr(sBotName), cStr("Bong! It's "+sTime+" US Eastern Time.")
' Change time zone info to that of your local machine.
' This if statement evaluates the current time and advances the timer one if drifted past the quarter hour.
If minute(Time) = 1 Or minute(Time) = 16 Or minute(Time) = 31 Or minute(Time) = 46 Then
If second(Time)>30 Then tmrScriptTimer.tag = 1
End If
End If
End Sub
-
Lightning Man
- Posts: 53
- Joined: 2003-08-09 10:00
- Location: Wilmington, NC
-
Contact:
Post
by Lightning Man » 2003-09-06 19:43
Improved drift correction, changed interval mechanics so that you can do it in any interval that divides 60 evenly (1 minute, 2 minutes, 3 minutes, 4 minutes, 5 minutes, 6 minutes, 10 minutes, 12 minutes, 15 minutes, 20 minutes, 30 minutes, an hour.)
Code: Select all
' Quarter Hour Chime v 1.4
' by Lightning Man
' from InfoBot by HaArD
' with elements from Shadowtek
Dim sBotName, iMinutes, iChecker, iSynchT, sTime, sChecker
Sub main()
sBotName = "Chime"
iMinutes = 15 ' This number should be something that divides evenly into 60
tmrScriptTimer.interval = 60000
tmrScriptTimer.enabled = True
ResynchTag
End Sub
Sub tmrScriptTimer_Timer()
If tmrScriptTimer.tag = "" Then tmrScriptTimer.tag = "0"
tmrScriptTimer.tag = clng(tmrScriptTimer.tag) + 1
If cLng(tmrScriptTimer.tag) => iMinutes Then
tmrScriptTimer.tag = "0"
sTime = FormatDateTime(Time, vbLongTime)
colUsers.SendChatToAll cStr(sBotName), cStr("Bong! It's "+sTime+" US Eastern Time.")
iSynchT = minute(Time) Mod iMinutes
' Debugging line
' colUsers.SendChatToAll cStr(sBotName), cLng(iSynchT)
If iSynchT > 0 Then tmrScriptTimer.tag = iSynchT
End If
End Sub
Public Function ResynchTag
iChecker = minute(Now) Mod iMinutes
sChecker = minute(Now)
If iChecker = 0 Then tmrScriptTimer.tag = iMinutes Else tmrScriptTimer.tag = iChecker
' Debugging lines
' colUsers.SendChatToAll cStr(sBotName), cLng(tmrScriptTimer.tag)
' colUsers.SendChatToAll cStr(sBotName), cStr(sChecker)
End Function