Re: Preferences are cached
Re: Preferences are cached
- Subject: Re: Preferences are cached
- From: Ron Hunsinger <email@hidden>
- Date: Wed, 23 Oct 2013 13:50:50 -0700
On Oct 23, 2013, at 8:13 AM, Luther Fuller <email@hidden> wrote:
>
> My application does have it's own .plist preference file, but ...
> I need to be more specific.
>
> Suppose you have an AppleScripted application, let's call it "MyApplication". When "MyApplication" is launched, it gets the frontmost application and if it is not "SomeApplication" it quits.
> If it is "SomeApplication", then "MyApplication" reads a value from the preference file of "SomeApplication" and continues to perform some action based on that value … then quits.
>
> What would happen in this scenario:
> 1. User has "SomeApplication" open and frontmost.
> 2. User runs "MyApplication" … and obtains the desired result.
> 3. User modifies the preferences of "SomeApplication", changing the value, above.
> 4. User runs "MyApplication", again … but what is the result?
>
> Would "MyApplication" read the correct changed value in step 4 ?
Unpredictable. You have never had any way of knowing when "SomeApplication" updates its preference file. (Even "SomeApplication" doesn't generally know. It just tells the defaults system the new value, and the defaults system updates the file at its leisure.) All you know is that the preference file will be updated by the time the application has finished quitting, and you don't even know that if the application is force-quit.
However, I believe that a 'defaults read ...' shell command will read the correct value, even if it hasn't yet been written to disk. I don't know that for certain, though.
But a better way of getting a value from "SomeApplication" is to just ask it, as in 'tell application "SomeApplication" to set xxx to yyy'. Of course, that's only an option if "SomeApplication" supports it.
-Ron Hunsinger
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden