Author |
|
jwshome Newbie
Joined: July 02 2006
Online Status: Offline Posts: 17
|
Posted: December 31 2006 at 10:25 | IP Logged
|
|
|
I feel like I'm asking all the stupid questions on this site.
I have a simple macro to get the current temperature from a Yahoo web page. I am able to use ph_regexdiff to get the temperature value (as an integer) into the variable [GLOBAL2]. I then transfer this value into a global variable called CURTEMP. This seems to work fine - when I use Powerhome Explorer to check the value of CURTEMP the changes from the macro are accurately reflected.
Finally, I want to pop up the value in a message box. If I pop up [GLOBAL2], or "[GLOBAL2]", it shows the correct result; but if I pop up CURTEMP it evaluates to !.
I assume this has something to do with strings and numbers, but I've tried many iterations (using the number and string functions; using quotes, etc.) and can't quite figure it out.
Can someone explain the error I'm making? Thanks.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 31 2006 at 11:31 | IP Logged
|
|
|
CURTEMP is a Global Variable which needs to be surrounded with braces: "{CURTEMP}".
System variables use brackets, as you have found.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 31 2006 at 11:58 | IP Logged
|
|
|
No questions are stupid .
It could be some confusion concerning PowerHome's variables. Over time, the variables have evolved but some of the older naming has stuck.
PowerHome has the concept of two types of variables. System variables and Global variables. System variables are only stored within memory. Restart PowerHome and your system variables are wiped out. Global variables are user defined variables and are stored within the database. Whatever value you set for a global variable will remain throughout restarts and whatnot until you change the value.
The number and types of system variables are fixed (some system variables can be influenced by your database definition such as X10 devices however). Most of the system variables are specialized, holding a specific value for a specific purpose, but there are 3 sets of general purpose system variables called LOCAL, TEMP, and GLOBAL. They used to have 3 distinct purposes, but over time, this has blurred somewhat.
There are 10 LOCAL variables (LOCAL1 through LOCAL10), 10 TEMP variables (TEMP1 through TEMP10) and 20 GLOBAL variables (GLOBAL1 through GLOBAL20). The GLOBAL variables are just that, GLOBAL. They are visible from within any macro or formula and their values do not change unless changed (or a restart). These variables are completely different from the database global variables.
The differences between LOCAL and TEMP system variables is now a little blurred. Originally, LOCAL variables were a fresh copy with every execution queue process. Launch a macro, it got a fresh copy of LOCAL variables. If that macro called another macro, the second set of LOCAL variables would be blank and separate from the first macros LOCAL variables. The TEMP variables were similar to LOCAL variables except that the first macro would pass copies of it's TEMP variables to the second macros TEMP variables. This was only a 1 way copy. Changes made to the TEMP variables in the second macro would NOT flow back up to the first macro when the second macro exited and control returned to the first macro. This distinction has laxed in certain areas and alot of the time the LOCAL variables are available and passed down to sub programs and such. However, to guarantee expected operation, you should think of the LOCAL variables as being fresh with each new macro or posted formula.
Global variables (not the GLOBAL system variables) are completely user defined and always available in every scope of the program. Since they are stored within the database, there are length constraints on global variables. The maximum length for a global variable is 1024 characters. Since system variables are stored within memory, they are unlimited in their storage capabilities (there are practical constraints of course).
That should explain the two different variable concepts within PowerHome. With that said, they are referenced within code two different ways, which I suspect is your problem (took me awhile to get there didnt it). System variables are enclosed within brackets like so: [LOCAL1], [TEMP5], or [GLOBAL7]. Global variables are enclosed within curly braces such as {CURTEMP}. To display your variable, you probably just need to use "{CURTEMP}".
Hope this helps,
Dave.
|
Back to Top |
|
|
jwshome Newbie
Joined: July 02 2006
Online Status: Offline Posts: 17
|
Posted: December 31 2006 at 14:30 | IP Logged
|
|
|
excellent, thanks (for both explanations...)
|
Back to Top |
|
|
|
|