Announcement

Collapse
No announcement yet.

Need help with a script

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

  • Need help with a script

    I'm using this script to display my calendar events in a virtual device, and then have HS speak those events with an announcement. I'm trying to figure why this part of the code is not working "if msg="" then msg="No Events Scheduled". If there are no event the virtual device is just blank. I did ask in BLGData forum but didn't get a response so hoping anyone with scripting skills can help me out.

    PHP Code:
      sub Main(ByVal Parms As Object)     Dim ParmArray() as String     ParmArray Parms.tostring.split(",")     Dim tDevice ParmArray(0)     Dim tCalendar ParmArray(1)     Dim tDays cint(ParmArray(2))     Dim allEvents As Object()         Dim myemail as string="leonb5419@gmail.com"         Dim msg as string ""          allEvents hs.PluginFunction("BLGData""""GetCalendarEventsForXDays", new Object(){"leonb5419@gmail.com""Leon Bourque"1})         msg="<table>"     For Each ev As Object In allEvents            msg msg "<tr><td> " ev.StartTime " - " ev.Name "." "</td></tr>"     Next         msg=msg "</table>"         if msg="" then msg="No Events Scheduled"         hs.SetDeviceString(tDevicemsg.TrimtrueEnd Sub 
    Click image for larger version

Name:	Untitled.jpg
Views:	5
Size:	5.9 KB
ID:	1255981

  • #2
    It's because msg already contains "<table>" and "</table>" so msg="" can never be true.

    There are lots of ways to correct this but one would be:

    If Not Msg.Contains("-") Then msg="No Events Scheduled"
    Jon

    Comment


    • #3
      Excellent. That worked. Thanks.

      Comment


      • #4
        I spoke to soon This doesn't actually work. If there are no events it does store no events in the virtual device, however it also stores no events schedule even if there are events scheduled.

        Comment


        • #5
          I can't see how that can happen. Would you show a screen shot of the device when it shows scheduled events?
          Jon

          Comment


          • #6
            First pic without the line and second pic with the line

            Click image for larger version

Name:	image_72374.jpg
Views:	3
Size:	9.4 KB
ID:	1256646
            Click image for larger version

Name:	Untitled.jpg
Views:	4
Size:	11.0 KB
ID:	1256647

            Comment


            • #7
              Originally posted by jon00 View Post

              There are lots of ways to correct this but one would be:
              What are the others ways I can try?

              Comment


              • #8
                I must have done it wrong before. I have If Not Msg.Contains("-") Then msg="No Events Scheduled" in the script now and my events are showing up and when no events I get no events scheduled. Will test for the next few days but it appears to work. Thanks again.

                Comment

                Working...
                X