Getting a pop-up window for a paragraph

Get help using and writing Nisus Writer Pro macros.
Post Reply
pereelmagne
Posts: 13
Joined: 2015-06-27 01:38:22

Getting a pop-up window for a paragraph

Post by pereelmagne »

Hello,
I want to invoke a pop-up window for a selected paragraph. Just that. I don't want to do anything with said paragraph, only display it. My macro is like this:

Select Paragraph
$selection = TextSelection.active
Show Find Results $selection, "Selected paragraph"

Can anyone tell me what's wrong?
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Getting a pop-up window for a paragraph

Post by phspaelti »

Hi pereelmagne,

The Show Find Results command expects as argument a Hash where the key(s) have arrays of selection objects as values.
So you could modify your code as follows:

Code: Select all

Select Paragraph
$selection = TextSelection.active
$matches = Hash.new 'Selected Paragraph', Array.new($selection)
Show Find Results $matches
Try it and have a look at the result.

I just suspect that a better choice for what you are trying to achieve would be:

Code: Select all

$sel = Read Selection
prompt 'Selected Paragraph', $sel
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Getting a pop-up window for a paragraph

Post by phspaelti »

Actually the following would also work, but the result(s) display a bit different:

Code: Select all

$doc = Document.active
Show Find Results $doc.textSelections, 'Selected Paragraphs'
philip
pereelmagne
Posts: 13
Joined: 2015-06-27 01:38:22

Re: Getting a pop-up window for a paragraph

Post by pereelmagne »

Thank you very much.
All three solutions work well. I will keep all them in my notes.

Best wishes,
Pere
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Getting a pop-up window for a paragraph

Post by phspaelti »

A belated follow up about a Nisus feature that I had forgotten about. Nisus has a command "Edit > Select > Show Selection in Results Window", which would also achieve the desired effect.
philip
Post Reply