• 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
Read/Write Text Files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Read/Write Text Files


  • Subject: Read/Write Text Files
  • From: Oakley Masten <email@hidden>
  • Date: Tue, 30 Mar 2010 12:38:18 -0700 (PDT)

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”

22 71 -18 -35 6

 

 

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

 _______________________________________________
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

  • Follow-Ups:
    • Re: Read/Write Text Files
      • From: Luther Fuller <email@hidden>
    • Re: Read/Write Text Files
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: (resend)
  • Next by Date: Re: Read/Write Text Files
  • Previous by thread: Re: Different pictures into one document
  • Next by thread: Re: Read/Write Text Files
  • Index(es):
    • Date
    • Thread