Applescript In Web Page Objects

Posted on
Sat Jun 09, 2007 7:36 pm
wikner offline
Posts: 181
Joined: Nov 02, 2003

Applescript In Web Page Objects

Here is something I don't understand. I want to make a very simple web page which displays a variable. I don't know javascript or Python (but will learn them some day) but I acheive bug-free results (eventually) in Applescript.

I want to give the web page user the ability to modify the Indigo variable with constraints. So I created 2 icons, an up arrow and a down arrow and loaded them into the Library/Application Support/.../images/controls/static folder. I then put them on the page and selected Click action: Execute AppleScript. I put in an embedded line of appleScript which calls a routine that is present in a file loaded into the Attachments Folder. (Yes, I DO remember to reload attachments when I make changes to this file). This script increments or decrements the Indigo variable, then does string manipulation on it to format it for presentation on the Control page (it is a real number, but I want to limit the # of deicmal places).

Maybe it doesn't matter, but it may be important to note that I am doing all this using a remote server on my network. I edit scripts locally and then save them to the Attachments folder on the remote server. I edit Control Pages on the local Indigo client which is logged into the remote IndigoServer.

Here is the problem: I once I create the page, editing the script that is called when the icon is clicked has no effect. The old (bug-ridden)applescript is run. I have tried deleting the file in the Attachments folder and then loading in a new version (always selecting "Reload Attachments" afterward) with no effect. I could try deleting the whole control page and re-creating it, but I would rather not.

By the way, is there any way, besides inserting lots of log statements, to debug a script that is in the attachments folder? I use Script Debugger for Applescript development.

Thanks
Norman

Posted on
Sat Jun 09, 2007 8:48 pm
Matt offline
Posts: 406
Joined: Aug 13, 2006
Location: Northern Idaho

(No subject)

I don't think this will help, but, Why not embed the complete script in each of the cntrol buttons instead of having it point to a script?

Seems like the script required to modify the variable would only be a few lines long in each case.

Posted on
Sun Jun 10, 2007 8:12 am
wikner offline
Posts: 181
Joined: Nov 02, 2003

(No subject)

There are many reasons.
1) Code efficiency. In even this simple case I have 2 buttons, one for incrementing and one for decrementing. Its easier to call the same piece of code with a positive or negative argument. There will problably be other instances in the future where I want to increment or decrement a variable by a a non-integer value, or by an integer other than one. Plus this routine also formats the result so it has a defined number of decimal places in the answer. I only want to debug that once.

2) Code comprehensibility. I want to be able to understand what I did later. Having all the code related to a given project (I am currently working on sprinkler control and swamp cooler control based on temperature, humidity and other weather data) in one place makes debugging it and changing it easy. So my Cooler code file contains all the routines for operating and controlling the Swamp Cooler with comments at the start of each routine telling me from where in Indigo these routines are called. Scattering this code throughout Indigo as embedded applescript within events would create a maintenance nightmare. Call me old-fashoned, but I sometimes print out the whole code file and make edits and notations in pencil before I actually implement them in the code editor. I can't do that from Indigo.

3) It is very nice to use Script Debugger as my source-code editor.

Posted on
Tue Jun 12, 2007 1:44 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Applescript In Web Page Objects

Hi Norman,
wikner wrote:
Here is the problem: I once I create the page, editing the script that is called when the icon is clicked has no effect. The old (bug-ridden)applescript is run. I have tried deleting the file in the Attachments folder and then loading in a new version (always selecting "Reload Attachments" afterward) with no effect. I could try deleting the whole control page and re-creating it, but I would rather not.

I'm not sure what is going wrong here. Based on your steps, I believe it should work. Note that when you have the Control Page editor dialog open and you hit the Preview button to see it in a browser, that you are viewing a temporary preview page. The real page doesn't get updated until you OK out of the Control Page dialog. Could that be the problem (you aren't looking at the right page in the browser)?
wikner wrote:
By the way, is there any way, besides inserting lots of log statements, to debug a script that is in the attachments folder? I use Script Debugger for Applescript development.

Not that I have found. I always end up using log statements. You could copy/paste the contents that are in your attachments folder into a new script and debug it that way.... but it won't be run exactly the same as it is when it is an attachment script (you might need to add some tell "IndigoServer" blocks).

Regards,
Matt

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests