NISUS Archives

April 2011

NISUS@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:
Philip Spaelti <[log in to unmask]>
Reply To:
Date:
Mon, 4 Apr 2011 12:47:55 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (33 lines)
Just to elaborate some more:
On 4. Apr 2011, at 8:27 , Ţorvarđur Davíđsson wrote:

> I make a search in a macro and need to know whether something was found or not. How can I do that?

Rather than use "Read Selection" you can try things like this

$found = Find '.*', ‘Es’
if ! $found
	prompt "nothing found."
	exit
End 

The "Find" command has the value "true" (actually "1" ) if something was found otherwise "false" (0)

Another approach is to use the the '$' option:

Find '.*', ‘$Es’
if $0 == ‘’
	prompt “Nothing found”
	exit
end

This has the advantage that you can actually check what was found, using the variable "$0". But this will only work for single finds.

If you are doing "Find all" then you will end up with a non-contiguous selection (an "array" of selections). In that case however it might be much a better idea to work with the language of text objects, but it really depends on what you are trying to do.

What are you trying to do?


Philip Spaelti
[log in to unmask]

ATOM RSS1 RSS2