Re: read write basics
Re: read write basics
- Subject: Re: read write basics
- From: "Marc K. Myers" <email@hidden>
- Date: Thu, 05 Jul 2001 11:45:04 -0400
- Organization: [very little]
>
Date: Thu, 05 Jul 2001 05:24:59 -0400
>
Subject: read write basics
>
From: monk <email@hidden>
>
To: "applescript users (apple)" <email@hidden>
>
>
hi list
>
>
at a loss as to how to write a text file, just trying to get my i/o
>
framework going on a newbie script i'm throwing together
>
>
here's what i have so far, and i always end up with an 'execution error'
>
that the file i'm trying to write "wasn't found"
>
>
i expect there is some command that i need prior to writing the file, and
>
when i try 'create file . . . ' i get a 'syntax error' 'expected end of
>
line, etc. but found class name' (so it's a bad command i suppose), anyway:
>
>
copy (choose file) to _source
>
>
read _source as list using delimiter space
>
>
write result to file "myhd:desktop folder:new source"
Try this:
set _source to (choose file)
set fileID to (open for access _source)
set theText to (read _source as text)
close access fileID
set fileID to (open for access file "myhd:desktop folder:new source" ,
with write permission)
set eof fileID to 0
write theText to fileID starting at eof
close access fileID
List I/O doesn't work, at least I've never gotten it to work. It's
better to convert your lists to delimited text on output and convert
them back to lists on input. If your output is tab-delimited, you can
turn it back into a list this way:
set theList to (read _source as {text} using delimiters {tab})
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com"
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[7/5/01 11:44:56 AM]