• 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
Fw: Read Write Text File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: Read Write Text File


  • Subject: Fw: Read Write Text File
  • From: Oakley Masten <email@hidden>
  • Date: Wed, 31 Mar 2010 06:51:55 -0700 (PDT)

I just saw the way my question showed up on the list.
Very sorry about the poor formatting.
That will be the last time that I write my inquiry using Word.

Here is a much better version.

Oakley

-----------------------------------

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 File
      • From: hd <email@hidden>
  • Prev by Date: Re: Read/Write Text Files
  • Next by Date: (no subject)
  • Previous by thread: Re: iPhoto and selection
  • Next by thread: Re: Read Write Text File
  • Index(es):
    • Date
    • Thread