Re: How do I Read and Write a list to a file
Re: How do I Read and Write a list to a file
- Subject: Re: How do I Read and Write a list to a file
- From: Emmanuel <email@hidden>
- Date: Wed, 6 Nov 2002 22:46:13 +0100
At 12:12 AM -0800 06/11/02, Alan Kimelman wrote:
I have been unable to write a list to a file and read it again as a
list. Instead, the Applescript returns a string.
set t to {"abc", "def"}
tell application "Finder"
set Par to "Macintosh HD:Library:Scripts: My Mail:"
set doc to "New Doc"
set a to (Par & doc)
try
close access alias a
end try
set y to (open for access alias a with write permission)
set eof of y to 0
write t starting at 1 to y as list
set z to read y from 1 to get eof y
close access y
end tell
z returns a string "listTEXTabcTEXTdef" that is meaningless to me.
Please explain the syntax of listTEXT and please explain how I can
retrieve a list. Thanks.
By default "read" returns a string. Since you want a list, you've got to write:
-------------------
set z to read y from 1 to get eof y as list
--> {"abc", "def"}
-------------------
Totally unrelated, I mention that some experienced scripters advise
not to encapsulate lines in "tell" wrappers when it is not needed.
The script that you posted does not require "Finder", you can just
drop the "tell" and "end tell" lines.
Emmanuel
_______________________________________________
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.