Re: Read for 1000 until nearest space? - Almost
Re: Read for 1000 until nearest space? - Almost
- Subject: Re: Read for 1000 until nearest space? - Almost
- From: Joe <email@hidden>
- Date: Tue, 14 Oct 2008 14:05:31 -0700
At 1:21 PM -0700 10/14/08, Philip Aker wrote:
>I think that before the 'read until space' you'll probably need a test for 'get eof' and then a compare for the accumulated length or use an embedded try block.
I've got it now. I can't believe how long I worked on this just to help my youngest put her typed chapter outlines (10 - 40K) on her iPod!
Thanks for pinpointing exactly where the error was occurring. The extra try block did the job. I needed to generate an error in that try block to then end the script.
Here is the working, but unpolished script. It's so fast the files don't even line up in order on the desktop (as they did when I had logging turned on). ;-)
Joe
tell application "Finder"
set myfile to the selection as alias
set flname to name of myfile
end tell
set filcnt to 0
set fr to open for access myfile
try
repeat
set filcnt to filcnt + 1
set rd1 to read fr for 2000
try
set rd2 to read fr until space
on error
set chunx to rd1
set nfr to open for access file ((path to desktop folder as string) & filcnt & " " & flname) with write permission
write chunx to nfr
close access nfr
close access fr
error 128
end try
set chunx to (rd1 & rd2) as string
set nfr to open for access file ((path to desktop folder as string) & filcnt & " " & flname) with write permission
write chunx to nfr
close access nfr
end repeat
on error
try
close access fr
close access nfr
end try
end try
_______________________________________________
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