• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Called script won't store property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Called script won't store property


  • Subject: Re: Called script won't store property
  • From: has <email@hidden>
  • Date: Mon, 28 Feb 2005 22:16:41 +0000

kai wrote:

 > Both are saved "as applications".
 > When I run TestScriptCalled by doubleclicking it remembers the property
 value.
 When I call it from TestScriptCalling it can't remember the property.

Why not and what's the trick?

When you open a script application manually, it is automatically saved when it quits. This evidently doesn't happen with the run script command,

Applets load their stored script when launched and store the updated version, replacing the original, when quit. The 'run script' command performs a load-execute or compile-execute operation, depending on whether the direct argument is a file spec or a string; it doesn't store the new script object back to file afterwards.


Two solutions to the 'how do I update the applet's stored state _and_ get a response back from the run event' problem:

1. As you suggest, use 'load script' and 'store script' to load the script and execute it locally, then store the changed object back to file:

set f to alias "path:to:TestScriptCalled"
set scpt to load script f
set scriptResult to run scpt
store script scpt in f replacing yes
scriptResult

This is the usual approach with compiled scripts though might be a little rude for applets. There's a risk that this script replaces the applet's script while the applet is running; when the applet quits it will then overwrite these changes itself.

2. Save the applet as stay-open, allowing it to handle and reply to incoming Apple events normally. This is simpler and a bit more polite too.

HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: What is this?
  • Next by Date: Re: Re: Converting 'file:/' URL to MacOS path name...
  • Previous by thread: Re: Called script won't store property
  • Next by thread: Removing html tags
  • Index(es):
    • Date
    • Thread