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:
Þorvarður Davíðsson <[log in to unmask]>
Reply To:
Date:
Mon, 4 Apr 2011 13:43:12 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (104 lines)
Hello Bill,

On 04.04.2011, at 04:00, you wrote:

> 
> I'm not a coder, so maybe I'm missing something, but, where did you actually tell it to perform the search? I'm not seeing it above.
> 

You are right, you did not see it because it is irrelevant for the question. A search is made within the macro and this search returns a certain value (found or not found). If something is found then a command X should be executed. If nothing is found then a command Y should be executed. Therefore I need to know whether something was found or not.

The purpose of the whole macro is to include headlines written in bold in the Navigator pane so you can easily jump from one headline to another.

Imagine you download a formatted text document from the web. Many look like this:

This is a bold line

Some text. Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text. 

Some text. Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text. 

This is a bold line

Some text. Some text. Some text. Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text. Some text. Some text.


All you have to do now is to select the headlines (i.e. all the bold lines) and execute the menu command “Level 1” [Insert > Table of Contents > Include in TOC > Level 1]. 

Here is the whole macro:


Show Navigator
# There may be some headlines you don’t want to include such as the title of the document. If you forget to select text you’ll get an alert …
$textExpression = Read Selection
if $textExpression == ''
	prompt "You need to select some text."
	exit
End

Find All '(AnyCharacter)(1+)(Return)', ‘esau’
# This will find all bold lines in the selection you have made

# Now begins the part where I need to know whether something was found or not

$textFound = Read Selection
if $textFound == ‘’
	prompt “No bold lines found.”
# if nothing was found the macro stops
	exit
End

# Otherwise insert the bold lines into the Navigator

Level 1

# END OF MACRO


I’ll now take a close look at the suggestion made by Philip Spaelti, so I’ll be back again.


Ţorvarđur


> 
> -----Original Message-----
>> From: Ţorvarđur Davíđsson <[log in to unmask]>
>> Sent: Apr 3, 2011 6:27 PM
>> To: [log in to unmask]
>> Subject: Was something found, yes or no?
>> 
>> Hello,
>> 
>> I make a search in a macro and need to know whether something was found or not. How can I do that?
>> 
>> This tells me whether some text is selected in the document
>> 
>> $textExpression = Read Selection
>> if $textExpression == ''
>> 	prompt "You need to select some text."
>> 	exit
>> End 
>> 
>> 
>> It works fine, so why does *this* not work?
>> 
>> $textFound = Read Selection
>> if $textFound == ''
>> 	prompt "Nothing found."
>> 	exit
>> End 
>> 
>> 
>> I have also tried 
>> 
>> if $textFound >1
>> or
>> if $textFound >0
>> 
>> 
>> but that does not make any difference.

ATOM RSS1 RSS2