Scripts support

Posted on
Sun Jan 18, 2004 11:54 am
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

Scripts support

This is a little tease of the latest development version of Indigator, my Konfabulator widget that controls Indigo on a server via Applescript.

Image

I am requesting support for an Applescript call to obtain the available scripts within Indigo's Script menu. This will allow me to access that information for Indigator's use.

Thanks,

Rick

Rick

Posted on
Sun Jan 18, 2004 12:59 pm
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

Nice widget

Looks cool. I'm planning on releasing a widget this week that is just a single small 'switch' for controlling one unit. Right now it shows the current status of what the switch will do (i.e. click it when it is off and it will send an ON command), but for this first alpha I'm just letting people select house/unit codes so I can't track state changes made locally or through Indigo, etc.

Posted on
Sun Jan 18, 2004 2:22 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

This looks great! Have you been able to resolve the issues with connecting to other computers via Applescript?

Posted on
Sun Jan 18, 2004 3:36 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Scripts support

jrickmd wrote:
I am requesting support for an Applescript call to obtain the available scripts within Indigo's Script menu. This will allow me to access that information for Indigator's use.

Hi Rick,

That is looking good! What do you need the AppleScript call to do -- just return the names of the .scpt files? Do you want just the names or the complete filepaths? And do you need another verb to execute a script given its name?

Regards,
Matt

Posted on
Sun Jan 18, 2004 4:07 pm
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

(No subject)

gregjsmith wrote:
This looks great! Have you been able to resolve the issues with connecting to other computers via Applescript?


I ran in to the same problem you reported to me ONCE, Greg. Restarting my computer solved the problem so can't say that I've discovered any grand solution to what you ran in to. This version does have much more robust error checking and reporting though...

Rick

Rick

Posted on
Sun Jan 18, 2004 4:09 pm
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

Re: Scripts support

support wrote:
That is looking good! What do you need the AppleScript call to do -- just return the names of the .scpt files? Do you want just the names or the complete filepaths? And do you need another verb to execute a script given its name?


The script names with a verb to execute that script would do perfectly.

Thanks,

Rick

BTW, I intend to add another "hierarchy" for Variables to view and change the value of Indigo variables.

Rick

Posted on
Thu Jan 22, 2004 10:57 pm
Guest offline

(No subject)

gregjsmith wrote:
This looks great! Have you been able to resolve the issues with connecting to other computers via Applescript?


Of interest, I just updated to Panther on my home machine. Indigator broke. In researching it, it appears the applescript call to the server of

Code: Select all
get device "device name" exists


returned the number 1 in jaguar, but returns the string "true" in Panther? Matt, can you explain this? I guess I need to code for either a 1 or "true" returned in order to cover both Jaguar and Panther?

Anyway, the new version should work for all those who had problems before... :lol:

Rick

Posted on
Thu Jan 22, 2004 11:08 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

I'm not sure why this changed in Panther. What are you trying to do? Can you just say something like:

if device "device_name" exists then
   -- do something or set a variable
else
   -- do something different or set a variable
end if

Regards,
Matt

Posted on
Fri Jan 23, 2004 9:55 am
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

(No subject)

support wrote:
I'm not sure why this changed in Panther. What are you trying to do? Can you just say something like:

if device "device_name" exists then
   -- do something or set a variable
else
   -- do something different or set a variable
end if


Within Konfabulator, I must encapsulate the script to call within a string and use that string as an argument in a function call:

applescript(scriptString);

That function returns a value, so it may be the way Konfabulator interprets a return value in Panther vs Jaguar. Of interest, the Indigo server is still running Jaguar.

I CAN do it the way you suggest, it just works better for my purposes to check the return value of "exists".

Thanks,

Rick

Rick

Posted on
Fri Feb 06, 2004 1:48 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Scripts support

jrickmd wrote:
The script names with a verb to execute that script would do perfectly.

I've posted a new Indigo beta which has an new application property, script files, and a new verb, execute script:

http://www.perceptiveautomation.com/ind ... o_beta.dmg

script files returns a list of file URLs, so you will probably want to parse out just the file name for display in your UI. I couldn't just return a list of script names because you can have scripts with the same name inside different sub-folders within the Scripts folder. You can pass these file URLs directly to the execute script verb to have them run.

Once you get a chance to try these out, let me know how they work for you.

Regards,
Matt

Posted on
Sat Feb 07, 2004 7:46 am
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

Re: Scripts support

support wrote:
I've posted a new Indigo beta which has an new application property, script files, and a new verb, execute script:

http://www.perceptiveautomation.com/ind ... o_beta.dmg

script files returns a list of file URLs, so you will probably want to parse out just the file name for display in your UI.


Thanks, Matt. I'm working with it now. Does anyone know how to convert a string to a file URL or 'furl' which is what the execute script command wants?

Rick

Rick

Posted on
Sat Feb 07, 2004 8:20 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Scripts support

jrickmd wrote:
Thanks, Matt. I'm working with it now. Does anyone know how to convert a string to a file URL or 'furl' which is what the execute script command wants?

It should take just about any type of object that it can convert to a file url, including a string. But can you pass it one of the furls that is returned by the script files application property? I was thinking that you would keep the list returned by script files, and then pass one of those items to the execute script verb. You probably don't want to display the entire URL path inside your widget, but you could convert the furl items into strings and chop off everything to the left of the last ":" right before you post it to the UI (but still keep the entire furl around for passing the execute script).

Regards,
Matt

Posted on
Sat Feb 07, 2004 4:33 pm
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

Re: Scripts support

support wrote:
It should take just about any type of object that it can convert to a file url, including a string. But can you pass it one of the furls that is returned by the script files application property?


It does not work with a string. i have gotten it to work though. The way I was doing things made it too difficult to match the "chopped up" string (= file name) to the original furl. I do the re-assignment at the execute script call now with this:

--[url=applescript://com.apple.scripteditor/?action=new&script=set%20thePaths%20to%20script%20files%0A%0Arepeat%20with%20thePath%20in%20thePaths%0A%09set%20pathString%20to%20thePath%20as%20string%0A%09if%20pathString%20ends%20with%20%22tell%20G4Tower.scpt%22%20then%0A%09%09print%20pathString%0A%09%09execute%20script%20thePath%0A%09%09return%0A%09end%20if%0Aend%20repeat%0A]Open this script in a new Script Editor window[/url].

set thePaths to script files

repeat with thePath in thePaths
     set pathString to thePath as string
     if pathString ends with theScriptName then
          print pathString
          execute script thePath
          return
     end if
end repeat


with theScriptName being entered at runtime via Konfabulator. Anyway, a new beta of Indigator is ready for any who want to give it a go... Let me know at --[url=mailto:indigator at jrad dot com]indigator at jrad dot com[/url].

Thanks,

Rick

Edit: email addresses edited to prevent spam. I just got some spam to this address and could actually find this page via a Google search on this address. :x
Last edited by jrickmd on Tue May 04, 2004 3:12 pm, edited 2 times in total.

Posted on
Sat Feb 07, 2004 5:04 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Scripts support

Hi Rick,

It should work with a string, as long as the string is the full path to the script file. Something like this would work:

   execute script "MyDrive:Users:mattb:Documents:Indigo User Data:Scripts:SampleScriptToRun.scp"

However, I think the technique you are using now looks great.

Regards,
Matt

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 27 guests