Subject: | |
From: | |
Reply To: | |
Date: | Mon, 4 Apr 2011 06:55:01 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Upon reading the macro I see that you do have a find command in there, but your "textfound" section does not relate back to that find command. Instead it just reads the selected text again.
-----Original Message-----
>From: Þorvarður Davíðsson <[log in to unmask]>
>Sent: Apr 4, 2011 6:43 AM
>To: [log in to unmask]
>Subject: Re: Was something found, yes or no?
>
>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.
|
|
|