Reply to topic  [ 7 posts ] 
Removing (some) character attributes . . . 
Author Message

Joined: 2010-02-22 15:06:48
Posts: 98
Hello All,

I have the following very simple macro which I use to get rid of italics and bold, etc. on the word at the insertion point (it then moves the insertion point to the next word):
Code:
Menu ‘:Edit:Select:Select Word’
Menu ‘:Format:Character Style:Character Style’
Select End
Find ‘\m’, ‘E’
Select End
The trouble is, the macro works fine sometimes and other times will not remove the attributes. Any ideas about the better way to do the macro? I want to keep the typeface and font size and just remove things like italics, bold, underline, superscript, etc. (the "options" under Character palette).

Thanks in advance!
Josh


2010-08-16 11:47:38
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Hi Josh- I'm a bit confused by this line:
Code:
Menu ‘:Format:Character Style:Character Style’

Do you really have a character style called "Character Style"? Is that some kind of base/plain style you've configured?


2010-08-16 15:04:07
Profile WWW

Joined: 2010-02-22 15:06:48
Posts: 98
Hi Martin,

Thanks for the help. I don't have character style defined; when I made the macro (and new to NWP, which I still am!) I assumed that it was some sort of default (or neutral) definition that was applied to all characters. When I tried applying it to text with italics, bold, etc., it seemed to work (and does work about 50–80% of the time) to 'reset' the text, so that the italics, bold, etc, is gone, and so I build the macro around it. However, it also doesn't work consistently, and I haven't been able to figure out exactly why . . .

Thanks,
Josh


2010-08-16 16:53:38
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Hrm, well you must have added such a character style at some point. When I run your macro I am warned by NWP:
Quote:
Unknown menu item path:
:Format:Character Style:Character Style

Which is as I expect, since I have no such character style in my document.

But onward to the problem you're trying to solve! All your macro does is change the character style, which is just one part of the attributes NWP considers. Generally speaking, NWP gathers attributes like so:

1. Paragraph Style (eg: Heading 4)
2. Character Style (eg: Emphatic)
3. Manually applied attributes (eg: those applied using the Character palette)

Attributes found later in the list override those found earlier, eg: the "Unitalic" attribute found in the Heading 4 paragraph style is overridden by the "Italic" attribute found in the Emphatic character style. Your macro merely changes the character style, which still lets either the paragraph style or manually applied attributes add bold/etc to your text.

So, what to do? You'll want to add a manual "Unbold" attribute, so that it has the final word in the matter. You do that by toggling the bold menu, but only if it is check marked, eg:
Code:
If Menu State ':Format:Bold'
   Menu ':Format:Bold'
End

Now, you said you wanted to turn off all the character options. Some of those you'll want to toggle off like bold if necessary, but others are simpler because the menus provide direct "None" states. Here's the full macro:
Code:
Menu ':Edit:Select:Select Word'

If Menu State ':Format:Bold'
   Menu ':Format:Bold'
End
If Menu State ':Format:Italic'
   Menu ':Format:Italic'
End
If Menu State ':Format:Shadow'
   Menu ':Format:Shadow'
End
Menu ':Format:Baseline:No Super/Sub'
Menu ':Format:Underline:None'
Menu ':Format:Strikethrough:None'
Menu ':Format:Text Color:Black'
Menu ':Format:Character Case:No Case Change'

Select End
Find ‘\m’, ‘E’
Select End


2010-08-16 17:26:31
Profile WWW

Joined: 2010-02-22 15:06:48
Posts: 98
Hi Martin,

The 'character style' must have been an artifact of importing my Wordperfect documents that then got into my NisusNewFile when I was first getting NWP all set up—and I've always just assumed that it was a Nisus default style! I looked at the style, it has no content: it's based on 'none' and has no attributes at all (which may have been the key to its semi-success, I suppose).

Thanks very much for excellent help as usual. The macro works perfectly, but with one problem — once I've run the macro on a word, my usual macro (below) to make a word italic no longer changes that word's character attribute (the word remains without italics). However my Make Word Italic macro works as expected on words where I haven't run your new macro. Similarly, when I manually select a word that I've used your macro on and then press Cmd-i, that word does become italic.
Code:
Menu ‘:Edit:Select:Select Word’
Menu ‘:Format:Character Style:Emphatic’
Select End
Find ‘\m’, ‘E’
Select End
Any suggestions?
Thanks again,
Josh


2010-08-16 18:08:07
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
goldste4 wrote:
Thanks very much for excellent help as usual. The macro works perfectly, but with one problem — once I've run the macro on a word, my usual macro (below) to make a word italic no longer changes that word's character attribute (the word remains without italics).

Happy to help! So it all comes back to that 1 to 3 list of attribute considerations. Character styles come at #2, which means that manually applied attributes can override them. That's why your Emphatic character style doesn't do anything; the macro had applied a manual "Unitalic" attribute.

From what you've told me, it seems like you consistently work with character styles. So instead of having that first macro force "unitalic", let's remove all manually applied attribute that could disrupt the functioning of your plain "Character Style" style. The first macro then becomes:
Code:
Menu ‘:Edit:Select:Select Word’
Menu ‘:Format:Remove Attributes Except Styles’
Menu ‘:Format:Character Style:Character Style’
Select End
Find ‘\m’, ‘E’
Select End

That will leave your text with no manually applied attributes, so your Emphatic style can do its work. The only scenario where the macro will leave bold/etc intact now is if your paragraph style enforces that formatting, which is likely not an issue.


2010-08-16 20:24:27
Profile WWW

Joined: 2010-02-22 15:06:48
Posts: 98
Hi Martin, perfect! That solves (and explains) the problem. Thanks again, Josh


2010-08-17 04:55:11
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 3 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