Announcement

Collapse
No announcement yet.

Script problem, hopefully simple to fix?

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

  • Script problem, hopefully simple to fix?

    Hello,

    Ok, so I'm working with the following sample in my mcsMovement script:

    Code:
       
    			 dim myvar
    			 myvar = hs.GetVar("FirstMovementInDining")
    			 if StrComp(myvar, "TRUE") <> 0 then
    				'don't do anything right now. 
    			 else
    				mcs.AudreyWav "audkit","c:\program files\homeseer 2\html\audio\okaeri nasai.wav"
    				hs.SaveVar "FirstMovementInDining", "FALSE"
    			 end if
    But no matter what I do, when I compile in the movement.txt script file into the mcsMovement plug-in, and execute it, I get an error complaining about a type mismatch.

    If I use the same piece of code in a standard script file, there aren't any problems.

    Comments, please? I've been beating on this same 10 lines of code for an hour...

    Thanks,
    Chris

  • #2
    No obvious reason. Which line is the type mismatch error?

    Comment


    • #3
      That's another one of the problems. It's hard to tell what the offending line is, because the logs say 0 / 0.

      Are the logs any more accurate if the script isn't compiled in to mcsMovement?

      Thanks,
      Chris

      Comment


      • #4
        This error is typically with the Sub Main that is the first line of the script. Mine looks like

        Sub Main(sDeviceName)

        Selecting run from HS vs run optimized should only change when the script is parsed. If optiimized then it is parsed into memory once. When run from HS is is parsed each time it is run.

        Comment


        • #5
          Originally posted by Michael McSharry
          This error is typically with the Sub Main that is the first line of the script. Mine looks like

          Sub Main(sDeviceName)
          Hmm... The code sample that was posted is in the MotionSensorOn subroutine, one degree of separation from the Main routine. I used your movement.txt as a basis for parsing the sensor type and then switching on the specific sensor.

          So, 0 / 0 might very well refer to Main, but it wouldn't refer to the subroutine that the posted code sample is contained in.

          Originally posted by Michael McSharry
          Selecting run from HS vs run optimized should only change when the script is parsed. If optiimized then it is parsed into memory once. When run from HS is is parsed each time it is run.
          That's what's kinda funny about this -- there are no problems parsing it into memory the once; it's only when the actual event occurs is when there is an error message.

          And if I comment out the line that does the comparison (in this case, it's the StrComp, but out of sheer desperation, I tried many different combinations, including working with the values 0 and 1), thereby unconditionally speaking the wav file every time the motion sensor detects motion, there are no errors.



          Thanks,
          Chris

          Comment


          • #6
            I have never used StrComp. In my case the expression would be

            if myVar = "TRUE" then

            My next guess is that StrComp is expecting a string input, but myVar is a variant. You could try the following to confirm that theory.

            if StrComp(cstr(myVar),"TRUE") <> 0 then

            Comment


            • #7
              I know I tried "if myVar = "TRUE" then", but that didn't work either.

              It was probably the second thing I tried, right after trying "if hs.GetVar("FirstMovementInDining") = "TRUE" then", but no matter what combination I tried, I kept getting the "type mismatch" error if the "if" statement was included at all.

              I was, however, unaware of the "cstr" VBScript call. I looked it up, and I see what it does. I guess I could see if that helps any. I can give that a try that first thing tonight.

              Thanks,
              Chris

              Comment


              • #8
                Nope, that didn't do it either...

                5/23/2006 8:51:16PM mcsMovement Script Run Error Type mismatch / 0 - @ Line 0 col 0 on line 0 Type mismatch


                I'm not particularly married to this idea, and am willing to do "bad" things just to get past this problem. Do you have any other suggestions on how to save off a positive value and negative value in one script routine so I can get to it in another script routine?


                Thanks,
                Chris

                Comment


                • #9
                  Duh, you can tell I'm starting to catch a cold... The answer is right in front of me. I'll just use a virtual device to set/clear the flag. I'm all set from here...

                  Chris

                  Comment

                  Working...
                  X