Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: how do I increment a global variable? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 08 2007 at 13:33 | IP Logged Quote jeffw_00

how do I increment/decrement a global variable within a macro?

Thanks!
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: December 08 2007 at 14:08 | IP Logged Quote bhlonewolf

Probably a few ways to do it, but check out the ph_addtoglobal function ...
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 08 2007 at 16:39 | IP Logged Quote jeffw_00

umm, yeah - if it handles negative values as well -
that'll do it.

thanks!
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: December 08 2007 at 17:50 | IP Logged Quote bhlonewolf

It does.
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 08 2007 at 17:54 | IP Logged Quote jeffw_00

not in the obvious way, I needed to do...

ph_addtoglobal("SLEEPINCNT",double(-1))
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: December 09 2007 at 10:12 | IP Logged Quote bhlonewolf

Yeah, I could see that from an end user point of view. From a programmer's or a computer's point of view, all math is fundamentally addition. In most APIs and what not, it gets a little cumbersome to wrap variants like subtraction, et al. It's a fairly standard paradigm, but I see what you mean.   Just wait until you play with various DateTime APIs and to find yesterday, you add -1 days. :)
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 09 2007 at 10:33 | IP Logged Quote jeffw_00

sounds like you know your stuff, bh -I'm surprised you can't help me with..

http://www.power-home.com/forum/forum_posts.asp?TID=1548&PN= 1

8-}
/j

Edited by jeffw_00 - December 09 2007 at 10:34
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 09 2007 at 11:54 | IP Logged Quote dhoward

The problem with negative numbers is that they *must* have a space before and after the negative to work properly (not my restriction but the language Im programming in). Sometimes it works if you don't include the spaces, but for maximum compatibility, it's best to just always put them there. So it should work like this:

ph_addtoglobal("SLEEPINCNT", - 1)

HTH,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 09 2007 at 11:55 | IP Logged Quote jeffw_00

oh, well that's, ummm, so obvious 8-} (not!)

seriously - thanks for the tip, ain't computers ergonomic?

thanks Dave 8-}
/j

Edited by jeffw_00 - December 09 2007 at 11:55
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
bhlonewolf
Senior Member
Senior Member


Joined: March 29 2007
Online Status: Offline
Posts: 198
Posted: December 09 2007 at 12:21 | IP Logged Quote bhlonewolf

jeffw_00 wrote:
sounds like you know your stuff, bh -I'm surprised you can't help me with..

http://www.power-home.com/forum/forum_posts.asp?TID=1548&PN= 1

8-}
/j


Ha! Well, I'm a computer programmer and you're likely running some of my code now :} ... but when it comes to HA and PH, I'm a noob.   Some of it translates easily, but some stuff not so easily!
Back to Top View bhlonewolf's Profile Search for other posts by bhlonewolf
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 09 2007 at 12:26 | IP Logged Quote jeffw_00

Well, - I design chips for consumer products (used to design computers way back), so you may be using some of my stuff too 8-}

on the other - Dave, as always, had the answer
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: December 09 2007 at 12:32 | IP Logged Quote BeachBum

Well that puts me out of the "Do Loop" I come from the Main Frames days. Ever heard of MVS, QTAM, BTAM and how about old DOS?

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


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: December 09 2007 at 12:37 | IP Logged Quote jeffw_00

heard of MVS (I think), still use DOS
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: December 09 2007 at 12:48 | IP Logged Quote BeachBum

Nope.. different DOS. Before PCs all the way back to TOS (Tape Operating System) then DOS (Disk Operating System) and SVS (Single Virtual Storage) then MVS (Multiple Virtual Storage) and VM (Virtual Machine).

__________________
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