Reply to topic  [ 7 posts ] 
Get "hidden" text - sort of 
Author Message
User avatar

Joined: 2008-05-25 12:41:12
Posts: 37
Location: Germany
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:
#NisusMacroProperty Name: Format {text}
# Begin Macro
Find "({.+?})", "Ea"
Set Font Name "Myriad Pro Semibold", true # set to any font you like
#End Macro


Code:
#NisusMacroProperty Name: Delete {text}, Print
# Begin Macro
Find and Replace "({.+?})\n?", "", "Ea"
Print... # this has to be language-localised (see "File" menu)
#End Macro


2008-06-15 02:35:22
Profile WWW
User avatar

Joined: 2008-05-25 12:41:12
Posts: 37
Location: Germany
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?


2008-06-15 02:58:45
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
You actually don't want to use the exact wording 'Undo Macro "whatever"', but just the bare command:
Code:
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:
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.


2008-06-16 14:54:07
Profile WWW
User avatar

Joined: 2008-05-25 12:41:12
Posts: 37
Location: Germany
Could I then close the copy without saving? This would fully automate the process.


2008-06-17 00:20:27
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2008-06-17 14:49:26
Profile WWW

Joined: 2008-07-07 18:39:56
Posts: 1
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?


2008-07-07 18:49:44
Profile
User avatar

Joined: 2008-05-25 12:41:12
Posts: 37
Location: Germany
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).


2008-07-07 20:24:16
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software