AppleScript plug-in changes in Indigo 1.1

Posted on
Mon Apr 21, 2003 1:42 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

AppleScript plug-in changes in Indigo 1.1

There is now a beta of Indigo 1.1 that has improvements to the way script attachment plug-ins are managed. The beta can be downloaded at:

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

-- Important -- this is a beta, so be sure and back up your database (.indiDb) file before you use it. It seems pretty stable but not many folks have had their hands on it yet. There are some features and UI that are not functional yet, but they shouldn't cause too many problems. Those new features/UI will not work in this build.

The changes to the attachment plug-in model should be backwards compatible with the previous model.

Improvements:

Scripts in the _Attachments_ folder no longer have to be script applications. In fact, you will likely have better performance and fewer problems if you save your attachment plug-in scripts as type "Compiled Script". Existing script applications will continue to work but the limitations / problems with script applications will not be fixed. Use compiled scripts instead to avoid these issues.

All script attachments now share the same global context as Indigo. This means you can directly call AppleScript handlers (subroutines) defined in attachment scripts from an embedded Indigo script. You can also call directly back into Indigo from script attachments. For example, the following will work:

Embedded Indigo Script (inside a trigger or time/date action):

  log "about to call plug-in script"
  testFunc("isDaylight")
  log "returned from plug-in script"

Attachment plug-in script (saved as a Compiled Script inside the Scripts/Attachments/ folder):

  using terms from application "Indigo"
    on testFunc(varName)
      log "var name is " & varName
      log "var value is " & (value of variable varName)
      log "next sunset is " & (calculate sunset as string)
    end testFunc
  end using terms from


Note you do still need to use the "using terms from" phrase so that the script can compile, but no "tell app" to Indigo is needed. If you make changes to an attachment script, then you can choose "Reload Attachments" from the script menu to automatically reload those scripts into Indigo's global context.

Let me know if you have any problems!

regards,
matt
Last edited by matt (support) on Mon May 12, 2003 11:55 pm, edited 2 times in total.

Posted on
Mon Apr 21, 2003 8:47 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: AppleScript plug-in changes in Indigo 1.1

The build posted yesterday (beta 3) has a bug that causes some scripts to fail to compile, and causes instability when executing scripts that use the AppleScript duplicate command to make copies of Indigo database objects.

I replaced the old download above with a new beta 4 that fixes these bugs:

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

If you downloaded yesterday's beta 3, then please make sure you download beta 4. Indigo will be much happier if you do.

regards,
matt
Last edited by matt (support) on Mon May 12, 2003 11:55 pm, edited 1 time in total.

Posted on
Fri Apr 25, 2003 1:19 pm
sjmarbu offline
Posts: 11
Joined: Apr 08, 2003

Re: AppleScript plug-in changes in Indigo 1.1

Matt,

beta 4 is a big improvement, and provides a LOT more functionality for embedded scripts. Thanks!

My question: How do I refer to an Indigo Variable inside a script in the Attachments directory? Here's what I've tried so far, without success (the commented out lines don't work):

In the attachments directory, I've defined a script like:

using terms from application "Indigo"
on getOldSpeaker()
log "in getOldSpeaker"
-- log "oldSpeaker = " & oldSpeaker
-- log "oldSpeaker = " & variable oldSpeaker
-- log "oldSpeaker = " & value of variable oldSpeaker
-- log "oldSpeaker = " & value of oldSpeaker
-- log "oldSpeaker = " & (value of variable oldSpeaker)
log "oldSpeaker = " & (value of oldSpeaker)
return value of oldSpeaker
end getOldSpeaker
end using terms from

In the Variable List I've defined oldSpeaker as "Speaker, Kitchen".

In a trigger for X10 A6 I've defined:
log "testing"
getOldSpeaker()
log "done testing"

When I hit the Execute Action Now button, the log lists:
testing
in getOldSpeaker

!! Script Error: The variable oldSpeaker is not defined.


!! Script Error: The variable oldSpeaker is not defined.

ACTION: Test Trigger

12:10:25 PM, 4/25/03

Looks like my syntax is off, or there's no way to reference an Indigo Variable. Hope you can point out my syntax error!

Thanks,

Scot

Posted on
Fri Apr 25, 2003 1:58 pm
sjmarbu offline
Posts: 11
Joined: Apr 08, 2003

Re: AppleScript plug-in changes in Indigo 1.1

[quote="sjmarbu"]Matt,

The above tests were done with beta4 downloaded today (4/25).

Can you comment on my question?

Thanks,

Scot

Posted on
Fri Apr 25, 2003 6:00 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: AppleScript plug-in changes in Indigo 1.1

Hi Scot,

Try using quotes around the variable name, like this:

using terms from application "Indigo"
on getOldSpeaker()
  log "in getOldSpeaker"
  log "oldSpeaker = " & (value of variable "oldSpeaker")
  return (value of variable "oldSpeaker")
end getOldSpeaker
end using terms from

Posted on
Fri Apr 25, 2003 10:12 pm
sjmarbu offline
Posts: 11
Joined: Apr 08, 2003

Re: AppleScript plug-in changes in Indigo 1.1

Matt,

Yep, that does it. I've got control of the speakers and the thermostats now.

Thanks!

Scot

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 20 guests