Re: Oh-oh, another victim to scripting Mail [SOLVED!]
Re: Oh-oh, another victim to scripting Mail [SOLVED!]
- Subject: Re: Oh-oh, another victim to scripting Mail [SOLVED!]
- From: John Delacour <email@hidden>
- Date: Wed, 25 Jun 2003 14:10:26 +0100
- Mac-eudora-version: 6.0a23
At 5:17 pm -0700 24/6/03, Dave Stewart wrote:
By the way, I think I saw something from JD in the archives asking
someone why they were doing (eof + 1). In my case, without the +1 added
I lose the last character in the file. I did try the suggestion JD
offered in that mailing, but it over-wrote the entire file each time it
was run. Maybe I'm to green to see why (to date, AS is the only
language that leaves me feeling lost and scared...
If you were to quote your "something from JD" and your script that
loses a character, it would make it easier to see what's wrong.
If you open a file and simply write to it, you will write from the
beginning of the file unless you specify 'starting at eof'. While
the file is open, anything you write will be appended automatically
and there is no need to mention eof. The three routines below
demonstrate this
set fU to "/tmp/f"
set f to fU as POSIX file
open for access f with write permission
set eof f to 0
close access f
--1
repeat with i from 1 to 9
open for access f with write permission
write ("" & i) to f starting at eof
close access f
end repeat
set s1 to read f
--2
open for access f with write permission
set eof f to 0
close access f
open for access f with write permission
repeat with i from 1 to 9
write ("" & i) to f
end repeat
close access f
set s2 to read f
-- 3
open for access f with write permission
set eof f to 0
close access f
repeat with i from 1 to 9
open for access f with write permission
write ("" & i) to f -- *NOT starting at eof*
close access f
end repeat
set s3 to read f
{s1, s2, s3}
--> {"123456789", "123456789", "9"}
JD
.
_______________________________________________
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.