Read/Write Text Files
I want to read and write a preferences file for one of my
scripts.
Text File-------- example
April 5, 2010
"Macintosh
HD:Users:omasten:Desktop:Example.txt"
“Red” “Blue” “Green”
A date
A Path
3 colors
5 numbers [integers]
Easy enough.
Read the File---------
tell application "Finder"
activate
set theFile to Choose File
open for access theFile
set x to read theFile
close access theFile
set theData to Paragraph 1 of x
set theFilePath to Paragraph 2 of x
set theColors to Paragraph 3 of x
set theIntegers to Paragraph 4 of x
set theColorsList to words of theColors
display dialog item 3 of theColorsList
------à Green
set theIntegersList to words of theIntegers
display dialog item 3 of theIntegersList
------à 18 It should
be -18
end tell
So
what am I doing wrong here?
Is there a better way to read the lines?
Is there a better way to coerce the data into a list than using "Words of"
My head hurts!
Thanks
Oakley