Announcement

Collapse
No announcement yet.

Need a "countdown to a specific date script"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need a "countdown to a specific date script"

    sub main()
    dtStartDate = DateValue("12-11-2004")
    dtEndDate = DateValue("12-25-2004")
    strTimeToAnnounce = "8:01 PM"

    intDays = dtEndDate - dtStartDate

    strWhatToSay = "It's " & intDays & " days until Christmas"


    If dtEndDate >= Date Then
    intIndex = hs.NewEvent("CountDown")
    Set ev = hs.GetEvent(intIndex)
    ev.misc = &H10
    ev.ev_date = Date
    ev.ev_time = strTimeToAnnounce
    ev.ev_abs_time = 0
    ev.speech = strWhatToSay
    End If
    end sub

    I tried what Rupp posted in the Script Libary, but got this error in my log:

    <TABLE cellSpacing=2 cellPadding=0 width="100&#37;" border=0><TBODY><TR><TD class=LOGDateTime0 noWrap align=left>7/14/2007 3:41:39 PM </TD><TD class=LOGType0 align=left colSpan=3>Info </TD><TD class=LOGEntry0 align=left colSpan=8>Running script in background: countdown.txt</TD></TR><TR><TD class=LOGDateTime1 noWrap align=left>7/14/2007 3:41:39 PM </TD><TD class=LOGType1 align=left colSpan=3>Warning </TD><TD class=LOGEntry1 align=left colSpan=8>Use of NewEvent is discouraged - please consider using NewEventGetRef or NewEventEx instead.</TD></TR><TR><TD class=LOGDateTime0 noWrap align=left>7/14/2007 3:41:39 PM </TD><TD class=LOGType0 align=left colSpan=3>Error </TD><TD class=LOGEntry0 align=left colSpan=8>Running script, script run or compile error in file: countdown.txt438:Object doesn't support this property or method: 'ev.speech' in line 17 More info: Object doesn't support this property or method: 'ev.speech'</TD></TR></TBODY></TABLE>
    Last edited by ant7797; July 14, 2007, 02:48 PM. Reason: added script

    #2
    Two minute conversion to VB.Net and new HS methods:

    Code:
    Sub Main(Optional ByVal pParms As Object = Nothing)
        Dim dtStartDate As Date = DateValue("12-11-2004")
        Dim dtEndDate As Date = DateValue("12-25-2004")
        Dim strTimeToAnnounce As String = "8:01 PM"
        Dim intDays As Double = (dtEndDate - dtStartDate).TotalDays
        Dim strWhatToSay As String = "It's " & intDays & " days until Christmas"
        If dtEndDate >= Now.Date Then
            Dim ev As Scheduler.Classes.EventClass = hs.NewEventEx("CountDown")
            ev.misc = &H10
            ev.ev_date = CStr(Now.Date)
            ev.ev_time = strTimeToAnnounce
            ev.ev_abs_time = 0
            hs.AddAction(ev.evref, action_type_value.ACTION_SPEAK, strWhatToSay)
        End If
    End Sub
    Note: Code comes with no guarantees that it works. I just converted it untested as a pointer.

    One thing that looks dubious about the original script is the use of dtStartDate, or rather the disuse of it.

    Comment


      #3
      Here you go mate, Days to Reminder Script written by Steve Meyers.

      Will do just what you wish. You can see it in action on my Web page, address below, select Listings then Reminders.
      sigpic
      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"
      HomeSeer 3 V 3.0.0.318 with ALEXA (AKA Amazon Echo)
      BL Radar V2.0.217; BLRF V2.0.85.0; HS Touch V3.0.0.1034 X10 V3.0.0.42; PHLocation V3.0.0.38; Zwave V3.0.1.110; X10 V3.0.0.42
      BLBackup V2.0.39;ImperiHome3.0.0.20 All on Windows XP Pro

      Comment

      Working...
      X