Subject: | |
From: | |
Reply To: | |
Date: | Fri, 8 Jul 2011 08:54:38 +0100 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Inyo55 wrote on Thu, 7 Jul 2011 18:58:37 -0400:
>I am trying to return an error message if I script a find command in=20
>applescript using BBEdit. That is, if the searched string is not
present=
> in the=20
>text being searched, I want the script to display an error message and
ca=
>ncel=20
>the script.
>
>My syntax is:
>
>try
>find sigfindname searching in text 1 of text document 1 options
{search=20=
>
>mode:literal, starting at top:false, wrap around:false,
backwards:false, =
>case=20
>sensitive:false, match words:false, extend selection:false} with
selectin=
>g=20
>match
>on error errmsg
>display dialog errmsg
>end try
>
>sigfindname is a variable for a string created upstream in the
script.=20=
>=20
>
>The applescript totally ignores my command in the TRY statement. Any=20
>suggestions? I also tried using an IF/THEN command using a FALSE
result=20=
>
>returned, but that did not work either.
The same command in the related TextWrangler returns a record containing
at least a 'found' property, whose value is a boolean.
tell application "TextWrangler"
set findResult to (find sigfindname searching in text 1 of text document 1 options {search mode:literal, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match)
if (not findResult's found) then
display dialog "\"" & sigfindname & "\" not found" buttons {"Cancel"} default button 1 with icon stop
-- error number -128
end if
end tell
NG
|
|
|