• 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: kai <email@hidden>
  • Date: Sun, 27 Feb 2005 23:34:02 +0000


On Sun, 27 Feb 2005 13:33:00 -0700, Gnarlodious wrote:

run script "Rachel:TestScriptCalled"
display dialog the result

TestScriptCalled:

property someVariable : missing value
if someVariable is missing value then display dialog "first run"

set someVariable to "Script initialized"
return someVariable

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, which I suspect is similar to running a copy in memory. So I'd be tempted to load the script, run it, make sure the relevant values are modified - and then store it back in the script file. Here are a couple of variations of your 'TestScriptCalling' that work here (obviously with a different 'scriptFile' path):


------------------------------------

set scriptFile to "Rachel:TestScriptCalled"
tell (load script scriptFile)
	set scriptResult to run script
	set its someVariable to scriptResult
	store script in scriptFile replacing yes
end tell
display dialog scriptResult

------------------------------------

set scriptFile to "Rachel:TestScriptCalled"
script loadedScript
end script
set loadedScript to (load script scriptFile)
set scriptResult to run loadedScript
store script loadedScript in scriptFile replacing yes
display dialog scriptResult

------------------------------------

---
kai

_______________________________________________
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


  • Follow-Ups:
    • Re: Called script won't store property
      • From: Doug McNutt <email@hidden>
  • Prev by Date: Re: *Very* strange script / global variable behavior
  • Next by Date: Re: *Very* strange script / global variable behavior
  • Previous by thread: Re: Called script won't store property
  • Next by thread: Re: Called script won't store property
  • Index(es):
    • Date
    • Thread