Get "hidden" text - sort of

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
andreas
Posts: 37
Joined: 2008-05-25 12:41:12
Location: Germany
Contact:

Get "hidden" text - sort of

Post by andreas »

I needed a feature that would "imitate" hidden text like it is done in Word. I'm a teacher and like to have my model answers right next to the questions in tests, assignments etc.

As NWP does not have hidden text, I use a workaround that works very well. Model answers are set between curly brackets and one macro formats them in a different, bold font (so that I see them well when marking tests) another one deletes them and sends the document to the printer - that way producing a print wihtout model answers. Right afterwards I undo the delete and have my model answers back in.

Both macros are pasted below. Feel free to use them - no need to ask for licensing etc. (I didn't do them on my own, anyway - had some help from Nisus people).

Mind that you have to language-localise the print command to make it match your menu entry under "File > Print..."

If someone from Nisus wants to post this to the official macro repository, it's fine with me.

Code: Select all

#NisusMacroProperty Name: Format {text} 
# Begin Macro
Find "({.+?})", "Ea"
Set Font Name "Myriad Pro Semibold", true # set to any font you like
#End Macro

Code: Select all

#NisusMacroProperty Name: Delete {text}, Print
# Begin Macro
Find and Replace "({.+?})\n?", "", "Ea"
Print... # this has to be language-localised (see "File" menu) 
#End Macro
User avatar
andreas
Posts: 37
Joined: 2008-05-25 12:41:12
Location: Germany
Contact:

Re: Get "hidden" text - sort of

Post by andreas »

One question, though:

I tried integrating the Undo command in the macro (using the exact wording that command has after running the macro) but I couldn't get it to work - any ideas?
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Get "hidden" text - sort of

Post by martin »

You actually don't want to use the exact wording 'Undo Macro "whatever"', but just the bare command:

Code: Select all

Find and Replace '({.+?})\n?', '', 'Ea'
Print
Undo
However, this won't do what you want because the Print command is not modal, eg: commands appearing after the print command are run immediately, without waiting for the print to finish.

An alternative is to work on a copy of your document, instead of modifying the original:

Code: Select all

Require Application Version '3.1'

# copy the document
$doc = Document.active
$doc = $doc.copy
$doc.clearAndDisableUndoHistory # so it's easy to quickly close the temporary document after printing

# delete bracketed text and print
Find and Replace '({.+?})\n?', '', 'Ea'
Print
Also, one last tip: you don't need to have the "NisusMacroProperty Name" line. It's only included in the built-in macros so that macro names can be easily localized by our translators. For macros you author yourself, the file name will be used as the macro name in the menu.
User avatar
andreas
Posts: 37
Joined: 2008-05-25 12:41:12
Location: Germany
Contact:

Re: Get "hidden" text - sort of

Post by andreas »

Could I then close the copy without saving? This would fully automate the process.
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Get "hidden" text - sort of

Post by martin »

I'm afraid you can't fully automate the process by having the macro close the temporary document. The issue is the same as before, eg: that the Print command hasn't finished before subsequent commands are run.
bjcollins
Posts: 1
Joined: 2008-07-07 18:39:56

Re: Get "hidden" text - sort of

Post by bjcollins »

I have the same need for hidden text for exams, but I'm not a macro writer, so I am not sure what you mean by language localization. How do I need to modify the macro for American english localization?
User avatar
andreas
Posts: 37
Joined: 2008-05-25 12:41:12
Location: Germany
Contact:

Re: Get "hidden" text - sort of

Post by andreas »

It must be "Print" just like it reads in your "File" menu. In German the same menu command is called "Drucken..." (with the three dots).
Post Reply