Re: Newbie Q on self-executing log app
Re: Newbie Q on self-executing log app
- Subject: Re: Newbie Q on self-executing log app
- From: Andrew Oliver <email@hidden>
- Date: Wed, 26 Mar 2003 17:23:05 -0800
First, why are you enclosing the script in a "tell application "Finder"
block? There's nothing in your script that requires the use of the Finder.
Second, why are you using a 'tell application "Scriptable Text Editor" block
when you can read and write the log file directly. Also, if I remember
correctly, you can't launch new applications during the shutdown process, so
I'd be surprised if this works at all.
Instead, something like this should work:
set theDate to (current date) as string
set logFile to open for access file "path:to:log.file"
set fileEOF to get eof logFile
write ("Shutdown initiated at " & theDate & return) as string to [NOBREAK]
logFile starting at fileEOF
close access logFile
All in all, this is far more transparent/less obtrusive to the user, doesn't
require any additional application support beyond the standard additions,
and doesn't use the clipboard to pass data around.
Andrew
:)
On 3/26/03 4:51 PM, "email@hidden" <email@hidden> wrote:
>
I'm trying to set up a self-executing app to log the times of the day that a
>
computer is both turned on and off, which I had figured on placing aliases of
>
in the Startup Items and Shutdown Items folders (OS 8.6). To that end the
>
following was written:
>
>
tell application "Finder"
>
get (current date)
>
copy (result as string) to the clipboard
>
tell application "Scriptable Text Editor"
>
activate
>
open document "Macintosh HD:TemporaryStuff:untitled"
>
paste contents of clipboard
>
set (return) to last character of text
>
close document "untitled" saving yes
>
quit
>
end tell
>
end tell
>
>
However, apparently there's a bit of trouble coercing the current date to a
>
string, as the command "copy (result as string) to the clipboard" results in
>
the following error message:
>
>
--> Can't set the clipboard of "Wednesday, March 26, 2003 9:25:39 AM" to
>
B+scriptB;.
>
>
Is this not possible? Or do I need a subroutine to do this? Or, worse yet, am
>
I missing something obvious? If so how must one go about this and why?
>
>
Also could you offer pointers on how to make this self-executing; that is,
>
without that dialog box with the "Run" radio button.
>
>
TIA for your help.
>
>
Mike
>
email@hidden
>
**************************************************
>
"The work of the individual still remains the spark
>
that moves mankind forward." bIgor Sikorsky
>
_______________________________________________
>
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.