Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Loop Counter Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
RWCS
Senior Member
Senior Member
Avatar

Joined: October 28 2002
Location: United States
Online Status: Offline
Posts: 102
Posted: January 22 2009 at 08:18 | IP Logged Quote RWCS

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 View RWCS's Profile Search for other posts by RWCS Visit RWCS's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 22 2009 at 08:40 | IP Logged Quote BeachBum

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 View BeachBum's Profile Search for other posts by BeachBum
 
RWCS
Senior Member
Senior Member
Avatar

Joined: October 28 2002
Location: United States
Online Status: Offline
Posts: 102
Posted: January 22 2009 at 08:51 | IP Logged Quote RWCS

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 View RWCS's Profile Search for other posts by RWCS Visit RWCS's Homepage
 
RWCS
Senior Member
Senior Member
Avatar

Joined: October 28 2002
Location: United States
Online Status: Offline
Posts: 102
Posted: January 22 2009 at 09:01 | IP Logged Quote RWCS

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 View RWCS's Profile Search for other posts by RWCS Visit RWCS's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 22 2009 at 09:03 | IP Logged Quote BeachBum

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 View BeachBum's Profile Search for other posts by BeachBum
 
RWCS
Senior Member
Senior Member
Avatar

Joined: October 28 2002
Location: United States
Online Status: Offline
Posts: 102
Posted: January 22 2009 at 09:17 | IP Logged Quote RWCS

Help me scream

ph_addtoglobal ('COM_CNT', 1)

works as expected (Verify increments variable)

Bob
Back to Top View RWCS's Profile Search for other posts by RWCS Visit RWCS's Homepage
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: January 22 2009 at 09:20 | IP Logged Quote BeachBum

Good job Bob…

Edited by BeachBum - January 22 2009 at 09:20


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

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