Re: Creating a list
Re: Creating a list
- Subject: Re: Creating a list
- From: Axel Luttgens <email@hidden>
- Date: Sun, 30 Aug 2009 01:06:24 +0200
Le 29 août 09 à 23:36, Peter Baxter a écrit :
Hi people,
I'm trying to create a list from a text file of every word in it
that has 5 characters. This shouldn't be so hard, but I keep
failing in the task. Can anyone help?
(OS X 10.6)
set theFile to choose file
set thisText to ""
try
set fileRef to open for access theFile
set textTo to read fileRef
set myWords to words of textTo
on error errString
display dialog "There was an error reading the file because:" &
errString ¬
buttons {"OK"}
return
end try
Hello Peter,
Do you mean something like the following?
set theFile to choose file
try
set fileRef to open for access theFile
set textTo to read fileRef
set myWords to {}
repeat with myWord in words of textTo
if length of myWord is 5 then copy contents of myWord to the end of
myWords
end repeat
on error errString
display dialog "There was an error reading the file because:" &
errString ¬
buttons {"OK"}
return
end try
Of course, there could be some room left for improvement; but that's
another question... ;-)
Axel
_______________________________________________
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