• 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: Reading nested lists from a preference file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading nested lists from a preference file


  • Subject: Re: Reading nested lists from a preference file
  • From: "Arthur J Knapp" <email@hidden>
  • Date: Tue, 24 Apr 2001 10:06:00 -0400

> Date: Tue, 24 Apr 2001 14:00:38 +0900
> From: Yosuke Ichikawa <email@hidden>
> Subject: Reading nested lists from a preference file

> set thelist to {"a", "b", {"c", "d", "e"}}
> item 3 of thelist
> --> {"c", "d", "e"}

> ... I want to keep this nested list
> part as a separate preference file.

> I've tried the following script with the pref file written
> in several different forms.
>
> set PrefFile to alias "Macintosh HD:Desktop Folder:a"
> open for access PrefFile

Does the pref file need to be human-editable? If not, you can
use the "load script" and "save script" commands to create/save/
and restore your preferences. John Delacour has an excellent
site that describes how to do this:

<http://www.eremita.demon.co.uk/scripting/applescript/prefs.html>


> set PrefList to read PrefFile
> close access PrefFile
>
> -- with this data file; {"a", "b", {"c", "d", "e"}}

Right, so you want the data saved in "literal-notation" format,
as opposed to a pure-data format.

One thing you can use is the "run script" command, (thought it isn't
nessesarily the best way to go):

run script PrefList
-- > {"a", "b", {"c", "d", "e"}}


> In what sort of form should I prepare the preference file?
> And how should I let AS read it?

To be able to use the "as list" syntax, you need to save the
information to the file from AppleScript:

write {"a", "b", {"c", "d", "e"}} to myFile as list

However, there are well know bugs involved with the read/write commands'
ability to parse complicated lists structures, (lists in lists).




Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://www.vivaladata.com


  • Follow-Ups:
    • Re: Reading nested lists from a preference file
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Simple download question
  • Next by Date: Opening files in Photoshop.
  • Previous by thread: Re: Reading nested lists from a preference file
  • Next by thread: Re: Reading nested lists from a preference file
  • Index(es):
    • Date
    • Thread