Since we're on the topic, I decided to try an experiment. I tried to use applescript to write a script to highlight every paragraph where the second letter was an "i". Not a particularly sensible task, but just something to test. I ran it on a list of words with about 1,500 paragraphs.
The applescript looked like this:
Code: Select all
tell application "Nisus Writer Pro"
set docText to text of front document
repeat with i from 1 to count of paragraphs in docText
set para to paragraph i of docText
if length of para is greater than 2 then
if second character of para is equal to "i" then
Do Menu Macro with macro "Select Paragraph " & i
Do Menu Macro with macro "Highlight:Pink"
end if
end if
end repeat
end tell
The result is quite a show, as you can watch Nisus scroll through the file highlighting stuff.
Then I tried the corresponding task in Nisus Macro language. Trying to write it in the same manner is actually quite ridiculous. So the following is an applescript that sets a variable to an (uneconomical) Nisus Writer macro and then runs it.
Code: Select all
tell application "Nisus Writer Pro"
set NisusMacro to "Select Document Start
while Select Next Paragraph
$sel = TextSelection.active
if $sel.length > 2
if $sel.subtext.characterAtIndex(1) == 'i'
Highlight:Pink
end
end
end"
Do Menu Macro with macro NisusMacro
end tell
While not a good way to do this task, this applescript beats the earlier one by quite a bit. After a short delay the action completes.
Note that here I wrote the Nisus macro into the applescript, but as mentioned earlier, one could just save the macro as a Nisus Macro in Nisus and then run it by calling by name from the
Do Menu Macro with macro command. But as I said, I wouldn't do this task this way in Nisus.
Of course the much better way to accomplish this task is to use
Find in Nisus.
Code: Select all
tell application "Nisus Writer Pro"
Do Menu Macro with macro "Find '^.i.+\n', 'Ea'"
Do Menu Macro with macro "Highlight:Pink"
end tell
This completes instantaneously.