• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to Read from Text File?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >How to Read from Text File? (From: Kurt Godden <email@hidden>)

  • Prev by Date: Re: How to Read from Text File?
  • Next by Date: Re: How to Read from Text File?
  • Previous by thread: Re: How to Read from Text File?
  • Next by thread: Re: How to Read from Text File?
  • Index(es):
    • Date
    • Thread