Reading input from a delimited source file
Reading input from a delimited source file
- Subject: Reading input from a delimited source file
- From: Joseph Weaks <email@hidden>
- Date: Wed, 8 Jan 2003 13:10:58 -0600
What am I doing wrong? I have a text file that has paragraph delimited
data. Basically, I want to read the content of the first paragraph, do
stuff with it, then repeat with each paragraph. Here's what I've been
trying:
-- Begin code snippet
Property sourceFile : "Source.txt"
set theSource to (open for access file ((path to desktop as string) &
sourceFile as string)
set AppleScript's text item delimiters to (ASCII character 13)
set sourceList to text items of theSource
repeat with x from 1 thru (length of sourceList)
set eachSource to item x of sourceList as string
-- do stuff with eachSource.
end repeat
close access theSource
-- End code
I'm getting a "Can't get every text item of ..." error.
Is there a better way to go about this? Some kind of
set eachSource to paragraph x of theSource?
Right now, each paragraph is only one word, so there's not a problem
loading the whole file into memory. I would like to also see a nice clean
handler that works if the source file is too long to load all at once.
_______________________________________________
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.