Re: Script Debugger: select contents of a handler by name
Re: Script Debugger: select contents of a handler by name
- Subject: Re: Script Debugger: select contents of a handler by name
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 30 Dec 2001 00:02:12 -0800
On 12/29/01 11:51 PM, "Shane Stanley" <email@hidden> wrote:
>
On 12/29/01 12:33 PM, "Jason Bourque" <email@hidden> wrote:
>
>
> Hello,
>
>
>
> This is what I have but it doen't work.
>
>
>
> I want to select contents of a handler by name.
>
>
>
>
>
How about this:
>
>
set handlerName to "testHandler"
>
>
tell application "Script Debugger"
>
tell document 2
>
set x to contents
>
set oldDelims to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to {"on " & handlerName & "("}
>
set theOffset to length of text item 1 of x
>
set AppleScript's text item delimiters to oldDelims
>
select character (theOffset + 1)
>
balance
>
end tell
>
end tell
Ooh, I like that a lot better than mine, I forgot about 'balance'. But,
unless you're 100% consistent about always using "on", maybe:
tell application "Script Debugger"
tell document 2
set x to contents
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"on " & handlerName & "("}
set theOffset to length of text item 1 of x
if theOffset = length of x then
set AppleScript's text item delimiters to {"to " & handlerName & "("}
set theOffset to length of text item 1 of x
end if
set AppleScript's text item delimiters to oldDelims
select character (theOffset + 1)
balance
end tell
end tell
--
Paul Berkowitz