Saturday, August 19, 2017

#1 2005-10-12 02:58:24 pm

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

How do I find out what's going wrong with my script?

There are several techniques to debug scripts, or find out what the script is seeing in order to fix it.

Two of the simplest things to do this are to insert beeps (audible acknowledgements that all is or is not well), or to return information at crucial steps, either by way of a "return" command or by displaying a dialog.
Here is an example:

Applescript:

tell application "Finder"
   activate
   if exists folder "Images" then
       beep 2
   else
       display dialog "Folder does not exist." buttons "OK" default button "OK"
   end if
end tell

If you hear two beeps all is well, if not a dialog is presented.
Or consider this:

Applescript:

set prefs to path to preferences folder
display dialog prefs -- to see how the path is written by AppleScript

Using these two techniques are invaluable debugging tools. For step-by-step debugging, looks into Late Night Software's Script Debugger. Take a look also to the invaluable debugging tools in Satimage Software's Smile.


Filed under: Finder

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)