Re: Running from what?
Re: Running from what?
- Subject: Re: Running from what?
- From: "Christopher C. Stone" <email@hidden>
- Date: Sat, 25 Nov 2000 05:49:17 -0600
At 19:03 -0500 11/24/00, Dave Saunders wrought:
>
Is there a way to detect from where a script is being run? I'm creating a
>
suite of scripts that I intend be driven by a set of OneClick buttons, but
>
I'm also making them available from the OSA menu (and, during testing, I run
>
them with Script Debugger).
___________________________________________________________________________
Hello Dave,
I generally agree with Paul and usually embed my AppleScipts in OC.
I also use Script Debugger (and BBEdit).
If you feel you must have outside scripts (and I can understand the maintenance issues) then there are numerous ways to deal with error trapping.
Paul shows one; here's another:
A simple method is to have the calling button to write a log entry to a file when it is activated.
Time Stamp: 001125052353
Script Name :Test
Script Path: Minerva:System Folder:Scripts:Test
Calling App: BBEdit
Calling Btn: Test Button
On error your AppleScript could read the file and display the log item, or it could open the log file into your favorite editor.
You'll have to provide proper file paths for your system.
You can serialize the log or clear it with each run; whatever you wish. This script is serial only.
The logging operation takes less than 1 tick on my system.
---------------------------------------------------------------------------
OneClick Script
---------------------------------------------------------------------------
Variable errLogFile, app, scptFile, scptName
Variable tmr, tmStamp, logEntry, btnName, cr
app = Process.Name
btnName = Button.Name
cr = "<return>"
errLogFile = "Minerva:OC error log"
scptFile = "Minerva:System Folder:Scripts:Test Script"
scptName = File(scptFile).Name
tmStamp = (Replace "." (DateTime.DateString 149), "", 1)
tmStamp = tmStamp & (Replace ":" (DateTime.TimeString 21), "", 1)
logEntry = " Time Stamp: " & tmStamp & cr & "Script Name: " & scptName & cr
logEntry = logEntry & "Script Path: " & scptFile & cr & "Calling App: "
logEntry = logEntry & app & cr & "Calling Btn: " & btnName & cr & cr
File(errLogFile).Append = logEntry
AppleScript scptFile
---------------------------------------------------------------------------
I'm assuming you can roll-your-own error handlers in your AppleScripts.
HTH
Best Regards,
Chris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Christopher C. Stone
StoneWorks Computer Consulting
email@hidden
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~