Author |
|
fasttimes Groupie
Joined: March 12 2006
Online Status: Offline Posts: 63
|
Posted: March 16 2006 at 00:37 | IP Logged
|
|
|
Is there a sample library for scripts/formulas/macros/sendkeys anywhere?
I'd like to jump in, but seeing some previous stuff in action would be a big help first!
BTW, on the web interface, is there a section for triggers?
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: March 16 2006 at 06:10 | IP Logged
|
|
|
There is the sample database included with PH (phsample.db).
Regarding triggers, not if you mean included with the standard web pages.
|
Back to Top |
|
|
mcarter Newbie
Joined: March 11 2006 Location: United States
Online Status: Offline Posts: 2
|
Posted: March 16 2006 at 22:13 | IP Logged
|
|
|
So how do you open the phsample.db to see what is there /
__________________ Mark
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: March 16 2006 at 23:36 | IP Logged
|
|
|
You can look at the phsample.db database using the PowerHome Explorer by pressing F7 while in the Explorer. In the window that opens, browse to the phsample.db database (default c:\program files\powerhome\database\phsample.db).
If you want to actually launch PowerHome using the phsample.db database, edit the pwrhome.ini file in the PowerHome directory and change the DBF parameter in the [Database] section to point to the phsample.db file. Save and restart PowerHome and you'll be using the sample database. Reverse the steps above to go back to your database.
There is not currently a screen for triggers or macros in the web interface. This will be something that will be addressed in a future version.
Dave.
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: March 18 2006 at 17:16 | IP Logged
|
|
|
Dave,
As I mentioned in a previous thread I learn best by examples. I've been looking at the sample database and it is helpful but to test things out, it requires going back and forth between databases. I found I can't print out the macros and can't cut and paste them either(from the sample database to the actual database). You mentioned that it was possible to export macros but export in the file list is always greyed out. So the first question is how do you export a macro?
The next question is more of a suggestion. I'd like to see other examples of macros, triggers and formulas in use.
For example, I wanted to announce the time, day of the week and date. I looked at your announce hour macro in the sample database and constructed my own. It would probably have taken you 13 seconds to do this. It took me an hour and a half to get it working since I wasn't familar with the formulas or their syntax. I'd also like to get the weather. Altho the sample database has an example, I couldn't export, copy or print the first line correctly. I would like to post my announce Day and Date macro so others could use it, improve on it and save them the hour and a half it took me as a new user. I would like to do the same for the weather macro if and when I get it going. Just throwing up a message in the macro section would be of some help but I think either a specific section on macro examples with instructions and comments or maybe some examples in the help file would be more helpful. Any thoughts on this?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: March 19 2006 at 03:01 | IP Logged
|
|
|
I know exactly what you're talking about. The documentation is in serious need of rework with new and current samples and plenty of them. I will begin working on this shortly and it will be a part of the next release version.
In the meantime, to export a macro from the sample database, first open the PowerHome Explorer. Press F7 and select the phsample.db database file. Go to the Macro Header Screen, not the Macro Detail screen. Right click the macro of interest and select "Export" from the popup menu. The "Export" item in the Files menu is for reports. Choose a filename to save the macro to.
To import the saved macro into your current database, open the PowerHome Multi-Editor. Press Shift-F5 to switch to SQL mode. Press Ctrl-O to open the file you just saved. From the menu, choose Edit->Execute Script to execute the SQL script and import the macro.
The GETWEATHER macro is probably way out of date. Ive been meaning to update this and demonstrate the new RegEx functions within PowerHome. So below, find the latest GETWEATHER macro. This was thrown together pretty quick and was working when I tested it so it's possible that the search criteria I used will change. You should get the idea though.
It's longer than it needs to be because of comments I added. One comment I forgot to add is to edit the very first line and insert the zipcode for your area.
Let me know how this works for you and if you have any ideas that you would like to know how to do, just let me know and I'll post the code here. We'll start to build up a library.
Edit: Well, pasting the code did not really work that well because the search strings have embedded html. Download the GETWEATHER import macro from here: http://www.power-home.com/download/getweather.txt
Dave.
Edited by dhoward
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: March 19 2006 at 06:57 | IP Logged
|
|
|
Thanks Dave.
I've received the following error message when importing the Getweather macro:
SQLSTATE = 23000
[Sybase][ODBC Driver][Adaptive Server Anywhere]Integrity constraint violation: Primary key for table 'macroheader' is not unique. Any ideas?
Thanks.
P.S. I got it to work. Apparently I already had a GET WEATHER MACRO. Once I deleted it and executed the script it created a new macro which worked. By the way it's 54 degrees in your area right now.
Edited by nadler
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: March 19 2006 at 12:56 | IP Logged
|
|
|
Heh, beat me to it. Once I saw the "Primary key not unique" message, I knew you already had a GET WEATHER macro.
Glad it's working for you. It was late last night and I just put it together pretty quickly and it's a good way to demonstrate the new ph_regex functions. If you've looked at the previous GET WEATHER macros in either the sample database or posted elsewhere on the board, you can see that this new version eliminates a huge number of steps and makes parsing this kind of HTML much easier.
Let me know if you have any other questions or have an idea on something you'd like to do and don't know quite how to implement it and I'll put together a sample for you.
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: March 19 2006 at 16:59 | IP Logged
|
|
|
Nice Dave! Can't wait to dig into this when I get back home!
Nadler: I did a small tutorial on using PH. Look here.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: March 24 2006 at 13:54 | IP Logged
|
|
|
OK, the dissection questions:
ph_regexsnap is pulling (snapping out) the characters between...
"<nobr><b>" and "</b> °F</nobr>"
...and, "\(.+\)" means grab any charcter ("."), then any number of characters ("+")?
ph_regexdiff is getting anything between...
">Humidity:</td>~255<nobr><b>" and "%</b></nobr>"
Where "~255" means span multiple lines?
The next ph_regexdiff first looks for...
"<h4>Updated:"
...then <div id="b">
...then gets the characters between "<div>" and "</div>"?
Were each of these done because of the data/method involved, or did you mix it up to show the two functions?
If I got it down, this is sweet! 41 lines down to 10!
Edited by TonyNo - March 24 2006 at 13:57
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: March 24 2006 at 18:39 | IP Logged
|
|
|
Tony,
And 4 of those 10 lines were comments !
I used the two different functions to just try to mix it up a little and demonstrate the differences. Truth be told, it would really make more sense to have substituted the ph_regexsnap with another ph_regexdiff.
You've almost got it except for the functionality of the ph_regexsnap. You are correct in where the characters get snapped from. However, the \( character is the start of the "snap" and the \) is the end of the snap. The .+ means any number of characters.
So, you can use the ph_regexsnap function with up to 9 total "snaps" and they will all be concatenated together in the return value.
It sure is a lot sweeter than it used to be. These new functions should greatly simplify any HTML parsing operations .
Dave.
Edited by dhoward - March 24 2006 at 18:40
|
Back to Top |
|
|