Author |
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: January 22 2009 at 08:18 | IP Logged
|
|
|
I'm trying to establish a time out using a loop counter (will accept other suggestions for time out)
I've tried:
ph_setvar_a (3, {COM_CNT}, {COM_CNT} + 1)
ph_setvar_a (3, {COM_CNT}, integer({COM_CNT}) + 1)
ph_formula ({COM_CNT} = {COM_CNT} + 1)
ph_formula ({COM_CNT} = integer ({COM_CNT}) + 1)
ph_formula ({COM_CNT} = ph_formula (integer ({COM_CNT}) + 1))
ph_setglobal_a ({COM_CNT}, {COM_CNT} + 1)
ph_setglobal_a ({COM_CNT}, integer ({COM_CNT}) + 1)
ph_setglobal_a ({COM_CNT}, ph_formula (integer ({COM_CNT}) + 1))
Any suggestions?
Bob
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 22 2009 at 08:40 | IP Logged
|
|
|
I use loop counters except they decrement instead. ph_addtoglobal( "devicelevel", -15 ) . Question why the integer and what are the formulas, If statements? Maybe I’m missing something.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: January 22 2009 at 08:51 | IP Logged
|
|
|
Pete, Thanks for your post.
This shows how little I understand PH (I've only used it for 9 years). Aren't system variables denoted by [] and global variables denoted by {}?
I'm happy to use your suggestion (it would be nice to understand it). . .
I'm assuming "devicelevel" is a named variable in your global variable list?
Would this be used with a Formula or a Set Global?
Thanks again for your help.
Bob
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: January 22 2009 at 09:01 | IP Logged
|
|
|
I get a verify of 1 on:
ph_addtoglobal ("{COM_CNT}", 1)
I get a ! without the curly brackets and quotes.
Also if I use +1 instead of 1 I get the proverbial !
I would have thought the Verify would have actually incremented the Global Variable, not withstanding the 1, it didn't. When I get a few more of these syntax things out of the Macro I'll test it.
Edited by RWCS - January 22 2009 at 09:03
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 22 2009 at 09:03 | IP Logged
|
|
|
I setglobal “devicelevel to a number - PH_setglobal_a( "devicelevel", 255 ). I then decrement it - ph_addtoglobal( "devicelevel", -15 ) while I also so check it - if (ph_getglobal_n( "DEVICELEVEL" ) = 105 , 1, 4 ). This used to dim my lights - ph_insteon("mbr_bed", 17, (ph_getglobal_n("devicelevel"))) and do certain things at various dim levels.
Globals are designated by various types of brackets except when that are in their own global statements. I may have the wording jumbled but I think you get the jest.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
RWCS Senior Member
Joined: October 28 2002 Location: United States
Online Status: Offline Posts: 102
|
Posted: January 22 2009 at 09:17 | IP Logged
|
|
|
Help me scream
ph_addtoglobal ('COM_CNT', 1)
works as expected (Verify increments variable)
Bob
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 22 2009 at 09:20 | IP Logged
|
|
|
Good job Bob…
Edited by BeachBum - January 22 2009 at 09:20
__________________ Pete - X10 Oldie
|
Back to Top |
|
|