Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Using iOn, iOff enumerated variables. Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 18 2010 at 12:53 | IP Logged Quote RichardL

In my VBS code, if I use iOn, iOff, etc in my commands I get a Syntax Error. If I change these to their corresponding "17", "19", etc. all is OK.

Is there an include statement, or something I am missing?

Thank you.
Back to Top View RichardL's Profile Search for other posts by RichardL
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 18 2010 at 13:19 | IP Logged Quote BeachBum

If you see the syntax error at execution time in the log then this is a known error. There is a problem with false systax errors associated with Insteon commands.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: January 18 2010 at 14:22 | IP Logged Quote grif091

Where are you using ion and ioff? If the statement is being parsed by VBS it would not know of values that Powerhome would normally parse.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 18 2010 at 14:25 | IP Logged Quote RichardL

Thanks for the quick reply.

So I can use the iOn, iOff variables and ignore the Syntax Errors. The code will execute as it should?

Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 18 2010 at 14:28 | IP Logged Quote RichardL

Lee (just saw your reply) - Yes, I am using VBS. I am using it in PH.Insteon, PH.InsteonGroup, PH.InsteonGroupCU commands, and maybe a few others. Right now everything has 17, 19, etc, but better programming practice was to use the constants. I then saw the syntax errors and backed off.

Thanks.
Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 18 2010 at 14:37 | IP Logged Quote RichardL

I just did a simple test to manually run a trigger with a VBS attached to it.

The VBS had one PH.Insteon command in it.

If I use 17, the lights turn on.
If I use iOn, the lights do not turn on, and I get a syntax error.

Yes, this does either look like an issue with PH/VBS, or some form of "include" statement from PH is needed...

Back to Top View RichardL's Profile Search for other posts by RichardL
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 18 2010 at 15:33 | IP Logged Quote BeachBum

And CMD2 has the same value in both?

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: January 18 2010 at 16:18 | IP Logged Quote grif091

I scanned the powerhome directory/subdirectories and found nothing that defined ioff. Values like ion/ioff work in ph_xxxx calls as Powerhome is parsing and processing those statements. With various script syntax formats being supported by Windows Script Processor PH would have to have a unique file for each script format. Does not look like such an animal exists.



__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 18 2010 at 16:25 | IP Logged Quote RichardL

Pete - yes, the commands were identical:

rv = PH.Insteon("XBR-HH-Hall", 17, 250) vs.
rv = PH.Insteon("XBR-HH-Hall", iOn, 250)

Pete showed me way back about the script server checkbox that got me going there. I was hoping for something equivalent. I agree that the exernal WSH would need some form of a link.

Not a biggie, I'll define constants at the top of my code and run from there.

Thanks!
Back to Top View RichardL's Profile Search for other posts by RichardL
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 18 2010 at 16:29 | IP Logged Quote BeachBum

Sounds like a bug to me.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 18 2010 at 23:54 | IP Logged Quote RichardL

Yep, I tried to avoid that ugly word!   

I will end up editing all my VBS to use constants anyway. If things change, I can do a quick replace of my constants to iOn,iOff,etc.

I appreciate the help!
Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 21 2010 at 00:06 | IP Logged Quote RichardL

I tried using constants in the VBS, and it only works a specific way:

The following 2 examples will NOT work:

----

iOn = 17
iOff = 19

rv=PH.Insteon("ID", iOn, 255)

----

iOn = 17
iOff = 19
iOn = int(iOn)
iOff = int(iOff)

rv=PH.Insteon("ID", iOn, 255)

----


The following example WILL work:

----

iOn = 17
iOff = 19

rv=PH.Insteon("ID", int(iOn), 255)

----

VBS has no variable types, so the conversion to integer has to happen in the command itself.

I simply reverted back to using no constants, and the raw (17, 19, etc) values, easier...

Back to Top View RichardL's Profile Search for other posts by RichardL
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: January 21 2010 at 00:18 | IP Logged Quote grif091

So I did not go down the wrong path before, you are seeing a VBS syntax error from this and not a powerhome event log error.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: January 21 2010 at 02:43 | IP Logged Quote grif091

Did you try defining them as Constants

Const iOn = 17
Const iOff = 19

EDIT: The following works here ....

     Const iOn = 17
     ph.usermessage("test message from function")
     ph.usermessage("second message from function")
     rv=ph.insteon("ICON SWITCH TEST", iOn, 254)

Edited by grif091 - January 21 2010 at 09:39


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: January 21 2010 at 14:14 | IP Logged Quote grif091

Pete.   the reason this is not a bug is the example below also works and as you can see Powerhome knows nothing about ion10 and ion7. The ion variable is evaluated by the Microsoft Windows Script Host processing before Powerhome ever sees the statement. Without ion being defined to WSH it is null and is the equivalent to issuing ph.insteon("ID", , 254) which of course is invalid. From the example below you can see that WSH evaluated ion10+ion7, substituted the result, 17, which is now a valid value for Powerhome. Just as ion10 and ion7 are not passed to Powerhome, ion is not passed to PH. One could argue that PH should provide a file for every possible script format that WSH accepts so that values such as ion could be used. However, with all the other things that Dave needs to spend time on, I2 support, Extended command support, CC additions, etc, things that we cannot do without functional additions to PH, I think this is low on the requirements list.

     const ion = 17
     const ion10 = 10
     const ion7 = 7

     rv=ph.insteon("ICON SWITCH TEST", ion10 + ion7, 254)

Just the ramblings of a very dusty old man after vacuuming leafs for two days.



__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 21 2010 at 16:58 | IP Logged Quote BeachBum

Lee, I see your point but if ph.insteon doesn’t work as described in the Help file then maybe the Help file needs to be fixed to address the work around.
I just have to pickup palm fronds. …


__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: January 21 2010 at 23:06 | IP Logged Quote RichardL

Well I'm sure glad that the dust and leaves did not mar your tech side!   

So here I am a coder for a few decades and didn't think of the darn "const" - as they say "bust my buttons" that works! It's always good to share issues and ideas.

I'm real glad since I hate hardcoding things. Time to retrofit all that code (again)!

No palm fronds here, just some skiing on Saturday!   

Back to Top View RichardL's Profile Search for other posts by RichardL
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum