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: Dave Stewart <email@hidden>
- Date: Wed, 25 Jun 2003 10:01:21 -0700
On Wednesday, June 25, 2003, at 06:10 AM, John Delacour wrote:
>
>
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.
Yeah, I guess you're right there. ;-) Looking back through my history
from yesterday, the message I was referring to was from Dec 14, 1998
and read:
>
> On 13/12/98, Arch Getty wrote:
>
>
>
>
>
> > The following script worked under OS8.1. Now under 8.5.1, it
>
> doesn't.
>
> >
>
> > close access file "Archs Drive:Storage:general clip"
>
> > open for access file "Archs Drive:Storage:general clip" with write
>
> permission
>
> > write return & return & theText to file "Archs
>
> Drive:Storage:general clip" starting at (place + 1)
>
> > close access file "Archs Drive:Storage:general clip"
>
>
>
> Why the "+1" ?
>
>
>
> This works:
>
>
>
> set f to (path to desktop folder as string) & "ttrash"
>
> open for access file f with write permission
>
> set eof of file f to 0
>
> write "one two " to file f starting at eof
>
> write "three" to file f starting at eof
>
> close access file f
>
> open for access file f
>
> set s to read file f
>
> close access file f
>
> return s
I tried to modify my script similarly (including the "set eof of file f
to 0" line) and found it was overwriting the contents of the file (not
a surprise now that I think about it, but not what I was looking for
either). Therefore I played around with it until I got what was posted
previously (remove the +1 part to see the problem it is attempting to
fix).
Anyway, the now modified script line reads :
write theOutput to theLogFile as string starting at eof
This line replaces the two lines I had previously to get eof and write
to (endOfFile + 1), which gets rid of the ugly wart-covered stuff and
works like a charm.
>
>
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.
My problem wasn't while the script was running, the trouble was the
*NEXT* run of the script. I wanted each run of the script to append to
the end of the file. In other words, the script runs each night and the
log file should grow by one line each time (after a few years, this log
file should get pretty big:). I have that now with the above modified
line.
Thanks to you and to Shane Stanley for the very helpful input. With the
help of all the brilliant scripters on this list, maybe someday I'll
get to a point where AS doesn't send chills down my spine.
;-)
Dave Stewart
Aqua-flo Supply (Goleta)
email@hidden
A computer lets you make more mistakes faster than any invention in
human history with the possible exceptions of handguns and tequila.
_______________________________________________
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.