• 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: Pref files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pref files


  • Subject: Re: Pref files
  • From: John Delacour <email@hidden>
  • Date: Fri, 18 Apr 2003 21:30:48 +0100
  • Mac-eudora-version: 6.0a15

At 9:02 am -0700 18/4/03, David Graham wrote:

Now that you mention it, I do remember coming across this a long time ago and does seem to be simplest approach; I always look for the most complicated solution to a given problem! ;-) That said, I can't for the life of me figure out how to make the properties of the loaded script object accessible for the current script.

I thought the following code would make all of the properties of the "pref" script file available, but it doesn't seem to work. I've scanned the section on inheritance but can't seem to figure this out. Any help would be greatly appreciated.

property parent : load script alias "Macintosh HD:BlahBlah:OU_Settings"


Here's a demo routine not involving a file and using instead a script object, but the principle is the same. I personally don't bother with making the library a property of the calling script and see no point in it, but tastes vary.

All you need to remember is the key to pLib's record: |preferences|. Then you have access to the whole record whenever you want.



set pPath to "path:to:prefs"
(* set prefs to load script alias pPath *)
set pLib to prefs -- equivalent of above

set dDate to current date
set nName to "Albert"

tell pLib to set pPrefs to its |preferences|
try
set dDate of pPrefs to dDate
on error
set pPrefs to pPrefs & {dDate:dDate}
end try
try
set nName of pPrefs to nName
on error
set pPrefs to pPrefs & {nName:nName}
end try

tell pLib to set its |preferences| to pPrefs

get pLib's |preferences|
(* store script pLib in alias pPath with replacing *)

----
script prefs
property |preferences| : {} as record
end script
--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Pref files (From: David Graham <email@hidden>)

  • Prev by Date: "Lost script" bug confirmed by Apple
  • Next by Date: Help creating a simple? script please
  • Previous by thread: Re: Pref files
  • Next by thread: BUG: AppleScript compilation problems
  • Index(es):
    • Date
    • Thread