Reading nested lists from a preference file
Reading nested lists from a preference file
- Subject: Reading nested lists from a preference file
- From: Yosuke Ichikawa <email@hidden>
- Date: Tue, 24 Apr 2001 14:00:38 +0900
I'm working with a nested list. To give a simplified
example, I want the script to work like so;
set thelist to {"a", "b", {"c", "d", "e"}}
item 3 of thelist
--> {"c", "d", "e"}
...where the nested list is itself a list item in the
larger list.
Seems simple enough, but I want to keep this nested list
part as a separate preference file. I've never done this
before, and I cannot get AS to read it properly.
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
set PrefList to read PrefFile
close access PrefFile
-- with this data file; {"a", "b", {"c", "d", "e"}}
return PrefList
--> " {\"a\", \"b\", {\"c\", \"d\", \"e\"}}"
item 3 of PrefList
--> "\""
-- with this data file; {a, b, {c, d, e}}
return PrefList
--> " {a, b, {c, d, e}}"
item 3 of PrefList
--> "a"
-- with this data file; a, b, {c, d, e}
return PrefList
--> "a, b, {c, d, e}"
item 3 of PrefList
--> " "
-- with this data file; "a", "b", {"c", "d", "e"}
return PrefList
--> "\"a\", \"b\", {\"c\", \"d\", \"e\"}"
item 3 of PrefList
--> "\""
I've also tried reading _as list_, but this only gives a
list with the whole string as its single list item.
I've also tried reading _using delimiter {","}_, but this
breaks up the nested list, treating the brackets as part
of text and giving 5 list items instead of 3.
In what sort of form should I prepare the preference file?
And how should I let AS read it?
This must be simple but I can't figure it out!
Thank you for any input.
Yosuke Ichikawa
Obun Printing