At 07:52 p +0100 06/07/2007, [EMAIL PROTECTED] didst inscribe upon an electronic papyrus:

This version runs in BBEdit if available, otherwise TextWrangler:

tell application "Finder"
        if exists file "BBEdit.app" in (path to applications folder) then
                set theTextEditor to "BBEdit"
else if exists file "TextWrangler.app" in (path to applications folder) then
                set theTextEditor to "TextWrangler"

You might want to avoid those assumptions. I have *no* apps loose in the applications folder; all are in subfolders (yep, even apple apps).
Use this instead:

   exists application file id "com.barebones.bbedit"

and likewise for textwrangler.

Oooh, hold on... bug in Finder X -- 'exists' is not trapping errors like it should, so that'll need to be in a 'try' block. (I wonder if there's time to get this bug in for 10.4.10....)

        else

display dialog "This script is designed for BBEdit or TextWrangler; it may or may not work with another application."

                set theTextEditor to (choose application)
        end if
end tell

-- testing
tell application theTextEditor
        set tstart to (current date)
        set m to make new document with properties {contents:"foo"}
        tell front window
                repeat 200 times
                        select insertion point after last line
                        set selection to ((current date) as text) & return
                end repeat
        end tell
end tell
display dialog (current date) - tstart


--
------------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to