Hi,
on an error, I’d like to write a variable to a filelog and have a repeat continue. The script is a droplet.
Any help would be appreciated.
Thanks
David
Hi,
on an error, I’d like to write a variable to a filelog and have a repeat continue. The script is a droplet.
Any help would be appreciated.
Thanks
David
Something along these lines might do it…
set eF to (path to desktop as text) & "Error_Log_File"
set f to open for access eF with write permission
repeat with k from x to y
try
-- do the stuff that might error
on error theError
write (current date) & " : " & theError & space & YourVbl & return to f starting at eof
end try
close access f -- don't forget this in a place where it's sure to happen.
end repeat
Nice (& fast!), thanks. I’m sort of a complete newb and I’m getting an error. I don’t think I’m formatting the path to my txt file correctly. Any thoughts?
Hi,
actually, I corrected my error and this worked perfectly, except that I had to comment “theError”. I guess this would be where I put an error number should I know what the number is?
Thanks again.
Stonemtn
Sorry, I spoke too soon!
the script doesn’t continue after writing the error to the log. What I need is for it not to stop the script – is this possible?
Here’s what I have:
repeat with tFile in tFiles
tell application "Finder"
set tName to name of tFile
end tell
set tName to replaceText(tName, " 1.wmf", "_1.wmf")
set tName to replaceText(tName, " 2.wmf", "_2.wmf")
set tName to replaceText(tName, " 3.wmf", "_3.wmf")
set tName to replaceText(tName, " 4.wmf", "_4.wmf")
set tName to replaceText(tName, " 5.wmf", "_5.wmf")
set tName to replaceText(tName, " 6.wmf", "_6.wmf")
tell application "Finder"
set name of tFile to tName
end tell
end repeat
on error --error_message
write tName & return to f starting at eof
end try
close access f
end open
Thanks for your assistance.
Stonemtn
OK, forgive me for not doing more troubleshooting before asking for help. I see I had the try and on error outside of my repeat. That’s completely solved it.
Thanks
Stonemtn
I think you need the error check INSIDE the repeat. When the error happens, the script will jump to the “on error” part. If that happens inside the repeat, the repeat will continue. You might have to experiment with where exactly the try loop goes so that potential errors are logged.
repeat with tFile in tFiles
tell application "Finder"
set tName to name of tFile
end tell
try
set tName to replaceText(tName, " 1.wmf", "_1.wmf")
set tName to replaceText(tName, " 2.wmf", "_2.wmf")
set tName to replaceText(tName, " 3.wmf", "_3.wmf")
set tName to replaceText(tName, " 4.wmf", "_4.wmf")
set tName to replaceText(tName, " 5.wmf", "_5.wmf")
set tName to replaceText(tName, " 6.wmf", "_6.wmf")
on error --error_message
write tName & return to f starting at eof
end try
tell application "Finder"
set name of tFile to tName
end tell
end repeat
close access f
end open
Model: Mac G5 OS 10.3.9
Browser: Safari 312.3.1
Operating System: Mac OS X (10.3.9)