Working on multiple documents
Working on multiple documents
Dear Folks,
I'm new to NWP, long-time user of NW Classic. I made heavy use of multiple-document operations in NW Classic, such as search/replace on all open docs, save-all, and save-all-changed. I can't find similar functionality in NWP.
Am I missing something, or does NWP lack these seriously-useful operations?
If the latter, is there a way to write a macro that works across multiple documents?
pax / Ctein
I'm new to NWP, long-time user of NW Classic. I made heavy use of multiple-document operations in NW Classic, such as search/replace on all open docs, save-all, and save-all-changed. I can't find similar functionality in NWP.
Am I missing something, or does NWP lack these seriously-useful operations?
If the latter, is there a way to write a macro that works across multiple documents?
pax / Ctein
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
There are no built-in Save All or Find in all open document commands. However here's a macro that saves all your open documents:
Searching in all open document would be trickier, but one could manage it. What form the macro takes would depend on how you imagine the results should be presented. Should all found instances simply be selected in the open documents? Do you want a printout of the results?
Code: Select all
# We iterate through all open documents, stopping when we get back to the first document.
$firstPath = ''
While 1
# do whatever we want to the document
Save
# check if we’ve got all the way back to the first document
$savedPath = Document Property 'file path'
If '' == $firstPath
$firstPath = $savedPath
Elsif $savedPath == $firstPath
Exit
End
# move to the next open document
Window:Next Window
End
Dear Martin,
Thanks! If I assign a hot key to that macro, it'll work well enough. Save All and Save All Changed really need to be built into the next version, though.
I'm less interested in simple searches than search and replaces. I work on multiple documents at one time and I'm frequently doing garbage cleanup and reformatting on all of them. Having to step through them manually to make sure they're all in comparable states is a real pain.
I gotta say, based on only a few weeks experience, that I'm not a satisfied customer. Nisus Writer Pro is considerably less useful to me than Classic. Were Classic compatible with my new MacIntel, I'd have not bought this program. It's missing a lot of the useful global scope capabilities of NWC, it lacks a simple macro recorder, and it doesn't feel anything like Nisus. A whole new learning curve and not a better one, in my opinion. I'm not sure I'm any better off than I'd have been with Microsoft Word.
I've recommended NWC to people; I can't do the same for NWP. Hopefully Version 2 will be a lot better. I'd like to stay with you folks.
pax / Ctein
Thanks! If I assign a hot key to that macro, it'll work well enough. Save All and Save All Changed really need to be built into the next version, though.
I'm less interested in simple searches than search and replaces. I work on multiple documents at one time and I'm frequently doing garbage cleanup and reformatting on all of them. Having to step through them manually to make sure they're all in comparable states is a real pain.
I gotta say, based on only a few weeks experience, that I'm not a satisfied customer. Nisus Writer Pro is considerably less useful to me than Classic. Were Classic compatible with my new MacIntel, I'd have not bought this program. It's missing a lot of the useful global scope capabilities of NWC, it lacks a simple macro recorder, and it doesn't feel anything like Nisus. A whole new learning curve and not a better one, in my opinion. I'm not sure I'm any better off than I'd have been with Microsoft Word.
I've recommended NWC to people; I can't do the same for NWP. Hopefully Version 2 will be a lot better. I'd like to stay with you folks.
pax / Ctein
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Here's a macro that takes the PowerFind Pro expressions as entered into the Find window and applies them to all open documents:Ctein wrote:I'm less interested in simple searches than search and replaces.
Code: Select all
# gather the find and replace expressions
$findExpr = Read Find Expression
$replaceExpr = Read Replace Expression
# We iterate through all open documents, stopping when we get back to the first document.
$firstPath = ''
While 1
# do whatever we want to the document
Find and Replace $findExpr, $replaceExpr, 'Ea'
# check if we’ve got all the way back to the first document
$savedPath = Document Property 'file path'
If '' == $firstPath
$firstPath = $savedPath
Elsif $savedPath == $firstPath
Exit
End
# move to the next open document
Window:Next Window
End
Before you judge NWP too harshly, it might be best to keep in mind that Nisus Writer Classic 6.5 took more than 10 years of development. Nisus Writer on OSX has been around less than half of that.I gotta say, based on only a few weeks experience, that I'm not a satisfied customer. Nisus Writer Pro is considerably less useful to me than Classic.
Dear Martin,
Thanks! I can divine the general form from your two examples, if they don't do everything I need.
I've been a satisfied Nisus user since the days of the Powerbook 100. What is that; fifteen years? Something like that. I actually stopped at v6.0; I ran into some sort of init conflict which impacted the performance of 6.5 and never got around to straightening it out.
I've written well over a million published words and god knows how much email with Nisus Classic. You could say I'm a happy Nisus camper.
Or, at least, I was. I'll withhold final judgment until the next version.
pax / Ctein
Thanks! I can divine the general form from your two examples, if they don't do everything I need.
I've been a satisfied Nisus user since the days of the Powerbook 100. What is that; fifteen years? Something like that. I actually stopped at v6.0; I ran into some sort of init conflict which impacted the performance of 6.5 and never got around to straightening it out.
I've written well over a million published words and god knows how much email with Nisus Classic. You could say I'm a happy Nisus camper.
Or, at least, I was. I'll withhold final judgment until the next version.
pax / Ctein
Also, to work flawlessly this very useful macro or it's user should make sure thatHere's a macro that takes the PowerFind Pro expressions as entered into the Find window and applies them to all open documents:There's one thing to watch out for: there's currently no way to get the options that are set in the Find window. This means the options have to be hardcoded into the macro.Code: Select all
# gather the find and replace expressions $findExpr = Read Find Expression $replaceExpr = Read Replace Expression # We iterate through all open documents, stopping when we get back to the first document. $firstPath = '' While 1 # do whatever we want to the document Find and Replace $findExpr, $replaceExpr, 'Ea' # check if we’ve got all the way back to the first document $savedPath = Document Property 'file path' If '' == $firstPath $firstPath = $savedPath Elsif $savedPath == $firstPath Exit End # move to the next open document Window:Next Window End
a) the find window is out of the way before execution
b) all documents should have been saved at least once
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
js is almost completely correct. Only the topmost document window needs to have been saved. The reason is that the macro uses the first document's file path to determine when to stop looping through the open windows. New documents that have never been saved do not have a file path.
Here's an updated macro that ensures both of js' conditions have been met:
Here's an updated macro that ensures both of js' conditions have been met:
Code: Select all
$firstPath = ''
# warn the user that the active document must have been saved at least once
$savedPath = Document Property 'file path'
If '' == $savedPath
Prompt 'The top document must be saved.', 'For this macro to work properly, the topmost document must have been saved at least once. You will now be prompted to save this document.'
Save
$savedPath = Document Property 'file path'
If '' == $savedPath
Exit
End
End
$firstPath = $savedPath
# gather the find and replace expressions
Set Find Shown false
$findExpr = Read Find Expression
$replaceExpr = Read Replace Expression
# We iterate through all open documents, stopping when we get back to the first document.
While 1
Window:Next Window
# do whatever we want to the document
Find and Replace $findExpr, $replaceExpr, '*a'
# check if we’ve got all the way back to the first document
$savedPath = Document Property 'file path'
If $savedPath == $firstPath
Exit
End
End
Last edited by martin on 2007-11-12 18:44:03, edited 1 time in total.
-
- Posts: 42
- Joined: 2006-12-14 09:09:51
thanks!
now this is time saving macro that brings back some of the special functionality of the Nisus 'Classic' (3-6), that I really missed since NWE. Great!
You should put this macro in the macro repository, so that others can find it easy too?
Dirk
You should put this macro in the macro repository, so that others can find it easy too?
Dirk
Martin, the Nisus Macro Reference States (p 11) that the option * in 'Find and Replace' will "Use options currently set in Find & Replace dialog. You can still add additional options as you like." True? If so, how would the revised 'Find and Replace' statement look? Like this?There's one thing to watch out for: there's currently no way to get the options that are set in the Find window. This means the options have to be hardcoded into the macro.
Code: Select all
Find and Replace $findExpr, $replaceExpr, '*a'
-Steve
Update: Edited to match Martin's version in the corrected script above.
Last edited by ssampler on 2007-11-14 15:26:05, edited 3 times in total.
Working on multiple documents
Hi Martin,martin wrote: Here's a macro that takes the PowerFind Pro expressions as entered into the Find window and applies them to all open documents:
this is a very useful macro. Thank you very much.
Regards,
G. Beurlen
Rio de Janeiro RJ Brazil
Dear Martin and Steve,
Thanks so much. This provides me with a great template for building all sorts of global scope macros. I made really heavy use of global options in NWC for sorting and maintaining my correspondence. I'm getting a lot of them back, now.
Two last (I hope) questions:
1) What's the macro command or option for doing a "find previous" instead of the default "find next"? Probably in the manual, but I missed it (like I missed the * option).
2) I'd like to modify the macro template to halt on the first found item. IOW, something that does
"IF {item found} THEN [exit the macro and give scope to the window with the found item} ELSE {continue the macro's search for items}".
Not hard, but while I can read Perl adequately I can't really write it without LOTS of trial and error (mostly error).
Thanks!
pax / Ctein
==========================================
-- Ctein's Online Gallery http://ctein.com
-- Digital Restorations http://photo-repair.com
==========================================
Thanks so much. This provides me with a great template for building all sorts of global scope macros. I made really heavy use of global options in NWC for sorting and maintaining my correspondence. I'm getting a lot of them back, now.
Two last (I hope) questions:
1) What's the macro command or option for doing a "find previous" instead of the default "find next"? Probably in the manual, but I missed it (like I missed the * option).
2) I'd like to modify the macro template to halt on the first found item. IOW, something that does
"IF {item found} THEN [exit the macro and give scope to the window with the found item} ELSE {continue the macro's search for items}".
Not hard, but while I can read Perl adequately I can't really write it without LOTS of trial and error (mostly error).
Thanks!
pax / Ctein
==========================================
-- Ctein's Online Gallery http://ctein.com
-- Digital Restorations http://photo-repair.com
==========================================
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
The option for find previous is "r" for reverse or "b" for backwards, either one, eg:Ctein wrote:1) What's the macro command or option for doing a "find previous" instead of the default "find next"? Probably in the manual, but I missed it (like I missed the * option).
Code: Select all
Find $findExpr, '*r'
The find/replace commands all return the number of matches made, so this would suffice:2) I'd like to modify the macro template to halt on the first found item. IOW, something that does
Code: Select all
$count = Find $findExpr, '*r'
If $count > 0
Exit
End