Re: How to Read from Text File?
Re: How to Read from Text File?
- Subject: Re: How to Read from Text File?
- From: Chap Harrison <email@hidden>
- Date: Thu, 22 Jan 2004 17:46:58 -0600
I'll field that one! :-)
Here's a starting point, not knowing exactly how you wrote your string.
This creates a new file in my DOcuments folder called foo.txt, writes
the string 'hello world' to it, closes it, reopens it, and reads it
back.
If you want to read only a portion of the file, you'll need to do some
additional things with delimiters or byte counts.
-- start script
set myFile to ((path to (documents folder) from (user domain) as
string)) & "foo.txt"
set fid to (open for access file myFile with write permission)
set myString to "Hello, World!"
write "Hello, World" to fid
close access fid
set fid to (open for access file myFile)
set fooString to (read fid)
fooString -- "Hello, World!"
-- end script
PS - the 'read' command is a Standard Addition.
_______________________________________________
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.