Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: PSP’s again! Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 22 2003 at 20:39 | IP Logged Quote TonyNo

Dave,

Remember those gv() and macro() functions we worked on?

Any reason this would not work (combining the two in one onclick)?

<form>
Reminder:
<input type="text" name="remindert" maxlength=19 value="<% left( string( today()),19) %>" size="19">&nbsp;
<input type="text" name="reminder" maxlength=25 value="<% ph_getglobal_s( "REMINDER") %>" size="25">&nbsp;
<input type="button" value="Schedule" onclick="gv('REMINDER T', remindert.value)" + "gv('REMINDER', reminder.value)" + "macro('sched reminder');">
</form>

The gv's are being updated, but, the macro doesn't work.

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: March 24 2003 at 10:54 | IP Logged Quote dhoward

Tony,

I went searching through the board to see if I could find an example of your gv and macro functions but could not find what the code looked like anywhere. 

The important thing to remember is that a form can only be submitted once and that only one form can be submitted per page.  You can have multiple forms on a page or multiple actions per form, but only a single action (form submittal) can be done per page.

The only way I can see to accomplish what you want is to have a single javascript function that submits a sendkeys formula that does all the necessary ph_setglobal and ph_macro functions that you like.  You will only be submitting one time a single sendkeys formula.  That formula however can contain as many PowerHome functions as you would like.

If you could post samples of your gv and macro functions (or point me in the right direction as to where they are on the board), I could make a better guess as to why it isn't working but suspect it has to do with trying to submit a form more than once.

HTH,

Dave.

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 24 2003 at 22:33 | IP Logged Quote TonyNo

Here are the functions...

function gv(id,value)
{ document.execsendkeys.sendkeys.value = "ph_rtne(ph_setglobal_s('" + id.toUpperCase() + "','" + value + "'))";  document.execsendkeys.submit(); }

function macro(id)
{ document.execsendkeys.sendkeys.value = "ph_rtne(ph_macro('" + id.toUpperCase() + "'))";  document.execsendkeys.submit(); }

It's strange how the two gv's are updated, though!

 

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: March 25 2003 at 18:00 | IP Logged Quote dhoward

Tony,

That is wierd!  I don't know how it could actually do the submit twice so that both gv's can be updated except that maybe javascript is managing to get two submits out before the browser has a chance to update the page before the first submit refreshes the page.

I would guess that it may also not be consistent...sometimes updating both gv's and perhaps sometimes updating only one gv based upon machine speed and internet connection speed.  Normally, you should only get 1 form submit per page refresh.

Dave.

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 25 2003 at 19:59 | IP Logged Quote TonyNo

Thanks. I'll try and recode.

Tony

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 30 2003 at 23:12 | IP Logged Quote TonyNo

All better! For anyone interested, here is the function...

function remind(id1,val1,id2,val2)
{ document.execsendkeys.sendkeys.value = "ph_rtne(ph_setglobal_s('" + id1.toUpperCase() + "','" + val1 + "') + ph_setglobal_s('" + id2.toUpperCase() + "','" + val2 + "') + ph_macro('SCHED REMINDER'))";  document.execsendkeys.submit(); }

This function sets two global variables, then, calls the "SCHED REMINDER" macro. Here is the form that uses it...

<form>
Reminder:
<input type="text" name="remindert" maxlength=19 value="<% left( string( today()),13) %>" size="19">&nbsp;
<input type="text" name="reminder" maxlength=25 value="<% ph_getglobal_s( "REMINDER") %>" size="25">&nbsp;
<input type="button" value="Schedule" onclick="remind('REMINDER T', remindert.value,'REMINDER', reminder.value);">
</form>

This form allows you to schedule a verbal reminder to be played at the specified time. This works with the following macros, which creates a timed TTS event, and, speak the contents of the REMINDER variable...

[SCHED REMINDER]
10 | Create Timed Event | TELL REMINDER | "{REMINDER T}"

[TELL REMINDER]
10 | TTS | "{REMINDER}"

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 10 2003 at 21:42 | IP Logged Quote TonyNo

Okay, I figured out it can be a lot better this way...

function remind(val1,val2)
{ document.execsendkeys.sendkeys.value = "ph_rtne( ph_createtimedevent( 1, \'ph_tts('" + val1 + "')\', '" + val2 + "'))"; document.execsendkeys.submit(); }

Then...

<form>
Reminder:
<input type="text" name="remindert" maxlength=19 value="<% today() %>" size="19">&nbsp;
<input type="text" name="reminder" maxlength=50 size="25">&nbsp;
<input type="button" value="Schedule" onclick="remind( reminder.value, remindert.value);">
</form>

But! Something is wrong! Did I do something dumb again?

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 11 2003 at 13:25 | IP Logged Quote dhoward

Tony,

Ok, I checked the code and played with and got it working.  You were real close but I found two problems.  The first is that you need to make sure that the date/time format is in the form of yyyy-mm-dd hh:mm:ss.  You might be able to use other formats for the date, but just using the today() function by itself will cause the fractional seconds of the time to be in the wrong format.

The second problem was concerning your quotes and double quotes within the remind function.  Ive posted the fix below:

function remind(val1,val2)
{
  document.execsendkeys.sendkeys.value = "ph_rtne( ph_createtimedevent( 1, 'ph_tts(\"" + val1 + "\")', " + val2 + "))";
  document.execsendkeys.submit();
}

Also, one of the fixes for the date/time problem:

<input type="text" name="remindert" maxlength=19 value="<%string(today(),'yyyy-mm-dd hh:mm:ss')%>" size="19">&nbsp;

I think you're having too much fun with this .

Dave.

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 11 2003 at 17:52 | IP Logged Quote TonyNo

Thanks, Dave! Yeah, big fun!  Are there documented conventions on embedding quotes?

My first implementation of the Reminder function was a huge hit with the family, but, it was limited to only one reminder at a time. This will fix that problem.

Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 28 2003 at 10:21 | IP Logged Quote dhoward

Tony,

Im catching up on the board messages.

I don't really have any documentation on the embedding of quotes.  It gets a little hairy when you have to mix Javascript code and PowerScript code.  I'll give a try on some fast tips however:

1.  PowerScript will recognize strings surrounded by both single or double quotes.  If you want to embed a single quote within a string, surround the string with double quotes.  If you want to embed a double quote within a string, surround the string with single quotes.

2.  In PowerScript, you can also prefix a single or double quote with one or more ~ (tilde) characters to embed quotes.  For example...if you wanted to surround a string with single quotes and embed a single quote, you could do it like this:  'This is an embedded single quote ~' in the middle of this string'.

3.  In Javascript, strings are delimited by double quotes.  The escape character for Javascript is the \ (backslash).  If you need to embed a double quote within Javascript, prefix it with a \.

So in the above example...the Javascript is executed first within the browser.  I want to set a Javascript variable to a string which contains a PowerScript formula.  This PowerScript formula needs to contain a string which contains string.  So...We delimit the Javascript string (the PowerScript formula) with double quotes.  The first string in the PowerScript formula, we delimit with single quotes.  We now have a string embedded within the PowerScript string.  We delimit this one with double quotes because PowerScript allows you to place double quotes within single quotes.  But...the problem we have now is that the Javascript will see the double quotes and think they are the Javascript delimiters.  We fix this by escaping the double quotes with the Javascript escape character (the backslash).  Javascript will now just treat the \" character as a normal embedded double quote.  When Javascript is done with the string, the backslash will not be there.

Now, we could have done this several different ways.  We could also have delimited the innermost string with a ~'.  Javascript doesn't care...Javascript just needs to have any embedded double quotes escaped with the \.  So we could have escaped the innermost PowerScript string with the Powerscript escape character ~.  We could have also delimited the outer PowerScript string with double quotes escaped for Javascript.  We could also delimit all the strings with just double quotes but would have to use both Javascript and PowerScript escape characters.  I haven't tested it but the following should illustrate this: document.execsendkeys.sendkeys.value = "ph_rtne( ph_createtimedevent( 1, \"ph_tts(~\"" + val1 + "~\")\", " + val2 + "))";

Well I realize I probably said to much and made things about as clear as mud...but hopefully shedded a little light on the subject .

Dave.


 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 28 2003 at 12:22 | IP Logged Quote TonyNo

Heh! I'll read it carefully tonight!
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo'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