Re: reading a file in an applescript.
Re: reading a file in an applescript.
- Subject: Re: reading a file in an applescript.
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 21 Mar 2008 15:44:57 -0400
On Fri, Mar 21, 2008 at 3:35 PM, Doug Meade <email@hidden> wrote:
>
> Hi folks!
> New to applescript ...
> I'm trying to read a file in an applescript.
>
> I've tried a number of different syntax options.
> The most simple is:
>
> read theTextFile
Welll, that won't work, first of all, but what is the value of
"theTextFile"? Are you setting it to a file name, an alias, the
result of an open for access call, or what?
Here's a model:
set targetFile to (choose file with prompt "Pick a file")
set readHandle to (open for access targetFile)
set fileText to (read readHandle for (get eof readHandle))
close access readHandle
fileText
If you have a filename you want to read, instead of prompting the user
for the file interactively, then you should
set targetFile to file "Macintosh HD:this:is:where:it:is:foo.txt"
or
set targetFile to POSIX file "/this/is/where/it/is/foo.txt"
the rest is the same.
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden