Re: Stop Log
Re: Stop Log
- Subject: Re: Stop Log
- From: Barry Wainwright <email@hidden>
- Date: Tue, 08 Mar 2005 09:35:03 +0000
Title: Re: Stop Log
On 8/3/05 12:04 am, "Michael Terry" <email@hidden> wrote:
On Mar 7, 2005, at 2:09 PM, Gil Dawson wrote:
What happened to stop log and start log?
When I run the folowing script:
log "A"
tell application "Finder" to get name of disk 1
stop log
log "B"
tell application "Finder" to get name of disk 1
start log
log "C"
tell application "Finder" to get name of disk 1
with Script Editor 1.8.3 under either Classic or 9.2.2, it runs. But with Script Editor 2.0 (v43) under 10.3.8, it s a run-time error:
<<script>> doesn't understand the stop log message.
Is that just the way it is?
Yeah, it doesn't work and it's really irritating. But, it hardly ever gets mentioned, so most people must not use it. I would, though, if it freakin' worked!
Michael
Instead of logging in the scritp window, I often use this technique, which has the advantage that log entries are displayed as the script runs, whether you are in Script editor or running the compiled script within an app or as an appplet:
First, use a routine to set up the logging:
set logFileName to "nameOfThisScipt.log"
set headerText to "==========================" & return & "Run started: " & (current date) & return & "==========================" & return & return
try -- does the file already exist?
set logFilePath to ((get path to library folder from user domain) as text) & "Logs:" & logFileName as alias
on error
set logFilePath to ((get path to library folder from user domain) as text) & "Logs:" & logFileName
end try
try -- in case the file has been left open by an error
set logFile to open for access logFilePath with write permission
on error errMess
display dialog "error opening file" & return & errMess buttons {"OK"} default button 1
close access logFilePath
return -99
end try
set eof logFile to 0 -- remove this line to append to log
write headerText to logFile
tell application "Console"
activate
open logFilePath
end tell
Then, at appropriate points in the script you just put:
write “xyz” & tab & someValue & return to logFile
The Console then displays a nice scrolling window of the data written to the log file, in real time.
--
Barry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden