that is a very interesting problem. I assume that the problem is that the “Find All” is evaluated via the GUI, and therefore does not keep up with the macro execution. Why this problem only appears since NWP (or since El Capitan?)—and not before--I can’t imagine. I’ll have to ask Nisus about that.
Here is a rewritten version that works. This will only work in NWP 2.1.X., not in earlier versions. (If necessary it could be rewritten to work in 2.0.X.)
### Find All in All Open Documents ###
# Type a find expression in the Find panel and run the macro.
# The Find operation will be done using options you have set in the Find panel.
Require Application Version '3.1'
$docs = Document.openDocuments
# get document objects of all open documents and put them in $docs (array)
if ! $docs.count # same as "if $docs.count == 0"
Exit 'No open document, exit...'
end
$findExp = Read Find Expression
$results = "Find: $findExp\n\n"
foreach $doc in $docs # for each document of all open documents...
Document.setActive $doc # make the document active
$f = $doc.text.findAll $findExp, '*' # do Find All and get the number of founds
$windowTitle = $doc.displayName # get the name displayed in the title bar
$results &= $f.count & " found(s) in $windowTitle\n" # append a report to $results (variable)
end
Document.setActive $docs.firstValue # make the first document active
Exit $results # show the results in the Exit dialog box
### end of macro ###