Re: Reading input from a delimited source file
Re: Reading input from a delimited source file
- Subject: Re: Reading input from a delimited source file
- From: Jay <email@hidden>
- Date: Wed, 8 Jan 2003 16:43:47 -0600
Hi Joseph,
Would something like this do what you're needing? (This just reads the
whole thing in at once)
-------------------------------------
set theSource to read (choose file)
repeat with x in theSource's paragraphs
display dialog x as string --just for testing
-- do stuff with each paragraph.
end repeat
-------------------------------------
Seemed to work in OS 10.2.3 with AS 1.9.1
Hope this helps.
Jay
On Wednesday, January 8, 2003, at 01:10 PM, Joseph Weaks wrote:
>
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.
_______________________________________________
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.