Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Error: Expected ')' 1

Status
Not open for further replies.

storm69

Technical User
Jan 31, 2006
26
US
Again, another question from a very green novice. I am using a home automation program that uses VB scripts. I am trying to get MS Agent to speak if a device flag (5 AM)is set (ON). Here is the script and I keep getting the following error no matter what I try.

Script Error: Line 350 Expected ')'

Rem **************************************************************
Rem Flag Device Event
Rem **************************************************************
sub Devices_FlagUpdate(Index)
with Devices.Flags
Select Case .Item(Index).State
Case dsOff
Case dsOn
If (.Item(5 AM).State) = Case dson Then
Character.speak "Tammy, I will have your coffee ready for you at 4 AM"
End If
Case dsIdle
End Select
end with
end sub

Can someone show me the error of my ways.
 
I guess that line 350 is:
If (.Item(5 AM).State) = [!]Case [/!]dson Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry, you were right. That is line 350. I had tried that before too and got the same thing. Just tried it again with:

Case dsOn
line 350 -> If (.Item(5 AM).State) = dson Then

and got;

script Error: Line 350 Expected ')'
If (.Item(5 AM).State) = dson Then
 
Is [!]5 AM[/!] really a valid index value ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm not really sure about that part. The "5 AM" is the actual flag name though
 
What about something like this ?
Sub Devices_FlagUpdate(Index)
With Devices.Flags.Item(Index)
Select Case .State
Case dsOff
Case dsOn
If .Name = "5 AM" Then
Character.Speak "Tammy, I will have your coffee ready for you at 4 AM"
End If
Case dsIdle
End Select
End With
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I tried that and got the following error;

Script Error: Line 350 Object doesn't support this property or method: 'Name'

Also, don't you have to know that the flag "5 AM" is true "Case dson
 
You don't have any documentation about this Devices object ?
 
I don't have any documentaion about the devices. I can tell you that the "devices" are coming from the home automation controller. These devices are both hardware, i.e. thermostats, temp sensors, motion detectors, etc and software, i.e. flags, time, etc.

I added the prefix .Item(Index). to name ... .Item(Index).Name and there were no errors and added an And to get the on (Case dson) state but got a syntax error.

If .Item(Idex).Name = "5 AM" And Case dson Then

Hopes this sheds some light on the subject
 
Did you ever read my post with timestamp 2 Feb 06 20:45 ?
The test is already inside the Case dsOn !
 
Yes, I did read that one. Like I said, I'm very green but trying to learn, sorry. I did run the script using:

If .Item(Index).Name = "5 AM" Then and there were no errors but it didn't execute the character.speak when the "5 AM" flag was set true. Thats why I asked about the Case dson.
 
I added the following line to the script and it did announce "5 AM is on" but did not announce the next "If" statement. So what am I missing here?

Rem **************************************************************
Rem Flag Device Event
Rem **************************************************************
sub Devices_FlagUpdate(Index)
with Devices.Flags
Select Case .Item(Index).State
Case dsOff
Case dsOn
Character.Speak .Item(Index).Name + " is on" <-- Added and worked
If .Item(Idex).Name = "5 AM" Then
Character.speak "Tammy, I will have your coffee ready for you at 4 AM" <-- Still does not work
End If
Case dsIdle
End Select
end with
end sub
 
If .Item(I[!]n[/!]dex).Name = "5 AM" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Can you give us more information about this "home automation program that uses VB scripts" ???

I am interested in software that will prepare the morning coffee... and evening dinner also!
 
Well, stupid me....that did the trick. You don't know how many times I've looked at that script trying to figure out what was wrong and missed it. Thanks for the second set of eyes.


As for the home automation program. It's the master and we humans are the slaves. It just tells us what to do and when to do it. Actually it is a special computer that controls just about everything in the house; i.e. lights, temp, time events, telephone, voice mail, security system, etc. A fun toy but way spendy...more than my wife...LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top