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

Joined: April 04 2007
Location: United States
Online Status: Offline
Posts: 199
Posted: May 12 2009 at 17:22 | IP Logged Quote kev21986

Is there an eval function? I am basically looking for a way to pass a formula to PH through a psp page with ph_getwebparm. Is this possible?

__________________
Kevin Smith
@respectTheCode
Back to Top View kev21986's Profile Search for other posts by kev21986 Visit kev21986's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: May 13 2009 at 07:36 | IP Logged Quote TonyNo

You want ph_formula() for your eval function.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
kev21986
Senior Member
Senior Member
Avatar

Joined: April 04 2007
Location: United States
Online Status: Offline
Posts: 199
Posted: May 13 2009 at 09:15 | IP Logged Quote kev21986

TonyNo wrote:
You want ph_formula() for your eval function.


Thanks. Ill try it tonight.

__________________
Kevin Smith
@respectTheCode
Back to Top View kev21986's Profile Search for other posts by kev21986 Visit kev21986's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 14 2009 at 22:01 | IP Logged Quote dhoward

Depending upon how I interpret your question, you may also want to look at the PH cgi function evalformula.

It takes two parameters, formula and nexturl, and allows you to submit a formula for evaluation to the PH webserver. A simple URL would look like this:

Code:
http://127.0.0.1/ph-cgi/evalformula?formula=ph_macro("YOUR MACRO ID")&nexturl=YOURPSPPAGE.PSP


Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
kev21986
Senior Member
Senior Member
Avatar

Joined: April 04 2007
Location: United States
Online Status: Offline
Posts: 199
Posted: May 15 2009 at 06:42 | IP Logged Quote kev21986

dhoward wrote:
Depending upon how I interpret your question, you may also want to look at the PH cgi function evalformula.

It takes two parameters, formula and nexturl, and allows you to submit a formula for evaluation to the PH webserver. A simple URL would look like this:

Code:
http://127.0.0.1/ph-cgi/evalformula?formula=ph_macro("YOUR MACRO ID")&nexturl=YOURPSPPAGE.PSP


Dave.


That is even better than what I was looking for.

evalformula isn't working for me, but formula is working great. One thing to note is that the formula needs to be URLEncoded. It looks like it will take a POST and that wouldn't.

Quick proof of concept
Code:
http://10.1.10.2:8080/ph-cgi/formula?formula=ph_devicecontro l(%22INSTEON%2BMSTR_FAN%2BOFF%22)


Edited by kev21986 - May 15 2009 at 06:43


__________________
Kevin Smith
@respectTheCode
Back to Top View kev21986's Profile Search for other posts by kev21986 Visit kev21986's Homepage
 
kev21986
Senior Member
Senior Member
Avatar

Joined: April 04 2007
Location: United States
Online Status: Offline
Posts: 199
Posted: May 15 2009 at 06:49 | IP Logged Quote kev21986

What about something like this

Code:
http://10.0.10.2:8080/ph-cgi/formula?formula=ph_getinsteonle vel(%22MSTR_FAN%22)


This returns a full html page with the result in the middle of it. Is there a way to get just the result?

__________________
Kevin Smith
@respectTheCode
Back to Top View kev21986's Profile Search for other posts by kev21986 Visit kev21986's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 15 2009 at 11:15 | IP Logged Quote dhoward

Kevin,

evalformula most likely worked (you can check the log), it just doesnt return the result to you. Its good to launch a macro or other command where you're not interested in the result and instead want to navigate to a particular page when done.

What you're looking for is /ph-cgi/eval. It takes a single parameter "formula". This will return the result only without any other data.

Also, look at the ph_htmlescape function for URLEncoding.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
kev21986
Senior Member
Senior Member
Avatar

Joined: April 04 2007
Location: United States
Online Status: Offline
Posts: 199
Posted: May 15 2009 at 11:40 | IP Logged Quote kev21986

dhoward wrote:
evalformula most likely worked (you can check the log), it just doesnt return the result to you. Its good to launch a macro or other command where you're not interested in the result and instead want to navigate to a particular page when done.

that makes sense.

dhoward wrote:
What you're looking for is /ph-cgi/eval. It takes a single parameter "formula". This will return the result only without any other data.

I will give that a try tonight.

__________________
Kevin Smith
@respectTheCode
Back to Top View kev21986's Profile Search for other posts by kev21986 Visit kev21986's Homepage
 

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