• 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: persistence of script properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: persistence of script properties


  • Subject: Re: persistence of script properties
  • From: kai <email@hidden>
  • Date: Sun, 6 Mar 2005 00:11:37 +0000


On Sat, 05 Mar 2005 07:18:44 -0800, Paul Berkowitz wrote:

On 3/4/05 11:18 PM, "Donald Hall" <email@hidden> wrote:

[snip]

Of course, when I rerun my script runner, I still get "x is 1", not "x is 2", which I would have gotten if 'x' had been saved by 'store script'.

Can anyone explain this?

Change the line

     run script theScript

to

    tell theScript to run

and you'll see what you were expecting;  "after run: theScript's x is 1", and then "2" on the next run, and so on.

You were using the osax 'run script'. 'run script' seems to run a separate instance of theScript in memory. It doesn't seem to affect the properties of the variable theScript representing the loaded test script, so when you store theScript you're just storing the same script object with the same values you started with. If you tell the loaded script to run, on the other hand, then its own property x's value is changed and later stored with the new value.

As Paul points out, the distinction between the Standard Additions 'run script' command (intended to act upon a script file or string) and the AppleScript 'run' command (normally sent to an application or script object) is significant - despite some semantic similarities.


Again, as discussed above (as well as in the recent "Called script won't store property" thread) the 'run script' command has no mechanism for storing changes within a script. It simply returns the result of the execution.

The 'load script' command (also from Standard Additions) loads a compiled script into the current script as a
script object - which is then an appropriate target for the AppleScript 'run' command. While this script object is running, it may make scripted changes to its properties. It then only remains to store the modified script in the original file (using the 'store script' command).


This might help to demonstrate the differences in persistence between the two commands:

--------

script s
	property p : 0
	set p to p + 1
end script

{|run script s|:{run script s, run script s, ¬
	run script s, run script s, run script s ¬
	}, |run s|:{run s, run s, run s, run s, run s}}

--> {|run script s|:{1, 1, 1, 1, 1}, |run s|:{1, 2, 3, 4, 5}}

--------

---
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


  • Prev by Date: Re: persistence of script properties
  • Next by Date: Re: persistence of script properties
  • Previous by thread: Re: persistence of script properties
  • Next by thread: The displayed name weird behaviour...
  • Index(es):
    • Date
    • Thread