MACSCRPT Archives

July 2011

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Stan Cleveland <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 7 Jul 2011 16:43:11 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
On Jul 7, 2011, at 3:58 PM, Inyo55 wrote:

> I am trying to return an error message if I script a find command in 
> applescript using BBEdit.  That is, if the searched string is not present in the 
> text being searched, I want the script to display an error message and cancel 
> the script.
> 
> My syntax is:
> 
> try
> 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
> on error errmsg
> display dialog errmsg
> end try
> 
> sigfindname is a variable for a string created upstream in the script.  
> 
> The applescript totally ignores my command in the TRY statement.  Any 
> suggestions?  I also tried using an IF/THEN command using a FALSE result 
> returned, but that did not work either.

Hi Bob,

I've run into something similar before, and found that this approach works around the problem:

	set itemNotFound to true -- default
	try
		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
		set itemNotFound to false
	end try
	if itemNotFound then
		display dialog "Some error message."
	end if

HTH,
Stan C.

ATOM RSS1 RSS2