Reply to topic  [ 9 posts ] 
I think I found a bug 
Author Message
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
When I type the follwing on my macro

Find All ‘.+’, 'EuaW'

And use any of the Gray colors for the attribute, it fails to find it. All the other colors are fine and it works in the Find window, juts not in a macro.

best
Lou


2009-04-05 23:26:01
Profile WWW
User avatar

Joined: 2007-01-17 03:25:42
Posts: 729
Dark Gray works fine for me but Gray and Light Gray can't be found.


2009-04-06 00:30:13
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Hi Lou,

Since the find works in the normal Find & Replace window, my first guess is that your macro has undesired attributes applied that you're not aware of. To be sure on this point, select all your macro text and then:

1. Choose the menu Format > Remove Attributes & Styles.
2. Choose the menu Format > Paragraph Style > Remove Style (this step is necessary because step 1 will introduce the Normal style if such a style exists).
3. Now apply text coloring to your find expression.

Let me know how it goes.


2009-04-06 09:48:10
Profile WWW
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
I can confirm Lou's problem, and whatever the value of Martin's remedy, it isn't applicable here. Here are the steps for reproducing the problem. Let's first try a case that works:

1. Open the find box
2. Enter '.+' as the find expression
3. Apply a text color (let's use "Red")
4. Test the find
---> It works. Red text is found.
5. Macroize the find expression
6. Test the macro
---> It works. Red text is found

If the same steps are repeated with "Gray" the macro just doesn't work.

_________________
philip


2009-04-06 17:21:11
Profile
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
Hi Martin,

I followed your post to the letter and the macro still did not find the gray color. I also re-did phspaelti's method and got the same result as he did.

best
Lou


2009-04-06 17:39:54
Profile WWW
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Here's is where I think the problem lies. When I open the macro and check the color of the find string, for "normal" colors the format menu will show the correct color checked. So if the find expression has the text color "Red" then "Red" will be checked. But with "Gray" even if apply and save "Gray" as the text color, next time I open the file the "Gray" is unchecked. Apparently NW cannot find the right color again. The text string looks gray, but it's attribute is not correctly identified as the "Gray" of the format menu. Presumably the bug is in the saving of the color attribute "Gray".

_________________
philip


2009-04-06 18:17:48
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Thanks for the investigation, that's exactly the cause of the problem. When saving color information to RTF the color can shift ever so slightly (likely imperceivably), so attribute sensitive matching cannot occur. I'll file a few bugs on this.

For what it's worth, if both the macro and target file have both been saved to RTF and reopened, the attribute sensitive matching should work.


2009-04-06 21:31:10
Profile WWW
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
Awesome. Thanks for everyone's diligence.

Lou


2009-04-08 00:21:21
Profile WWW

Joined: 2008-05-17 04:02:32
Posts: 400
It's too late for the fair but I have been following the thread with great interest. Personally I have seldom used the attribute sensitive find/replace. One of the reasons is that I often fail in getting it to work: it is not always easy for me to apply appropriate attributes on the find expression and remove those which are not.

So I began to think over how to simplify the process and, with help from Martin (thank you! I wrongly imputed the misbehaviour of an earlier version of the macro to NW Pro and sent a feedback), I could write a macro below which picks up character attributes from the selection (or insertion point) and applies them on the find expression.

If the find field is empty, Anything (PowerFind bubble) or its PowerFind Pro equivalent \p{Any}+ will be inserted.

Not having such a special character, Normal Find will use \p{Any}+ too with the find mode set to PowerFind Pro.

There is no ideal behaviour for such a macro. Someone may want to find text in superscript and blue regardless of font. Someone else may want to limit the target to text in a specific language. You can add any commands at the end of the macro so that it fits your needs.

Note that it does not use selected text for find but uses its character attributes only.

Code:
### Use Selection for Find Attributes ###

# This macro picks up character attributes from the selection
# (or insertion point) and applies them on the find expression.
# Note that it does not use selected text for find but
# uses its character attributes only.

# If the find field is empty, Anything (PowerFind bubble) or
# its PowerFind Pro equivalent \p{Any}+ will be inserted.

# Not having such a special character, Normal Find will use
# \p{Any}+ too with the find mode set to PowerFind Pro.

# There is no ideal behaviour for such a macro. Someone would
# want to find text in Times Italic regardless of font size.
# Some one else would want to find text in superscript and blue.
# You can add any commands at the end of the macro to make it
# fit your needs.

Require Pro Version 1.2
$sel = TextSelection.active
if $sel == undefined
   'No selection (or insertion point) found, exit...'
end

Set Find Shown false
Menu ':Edit:Copy:Copy Character Attributes'
$find = Read Find Expression
$replace = Read Replace Expression
$options = Read Find Options

if $find == ''  # if the find field is empty...
   if $options.find 'e', '-i'  # if the find mode is set to PowerFind...
      $anything = '{\rtf1 \mac \ansicpg10000 {\*\nisusfindcell '  # construct RTF code corresponding to Anything
      $anything &= '{\*\nisusfindcellident wild.anything}{\nisusfindcellname Anything}'
      $anything &= '{\nisusfindcellregex (?:.|\\\'5cn)+}}{\nisusfindcelltext (?:.|\\\'5cn)+}}'
      $find = Decode RTF $anything  # make it RTF
      Find and Replace $find, $replace, '*!'
   else  # PowerFind Pro or Normal Find
      $find = Cast to String '\p{Any}+'  # remove style attributes inherited from the macro file
      Find and Replace $find, $replace, '*E!'
   end
end

Set Find Shown true

Menu ':Format:Language:Any Language'
Menu ':Edit:Paste:Paste Character Attributes'
# Menu ':Format:Font:Any Font'  # optional (remove # at the line start to enable it)

### end of macro ###

Formatted macro file:
http://www2.odn.ne.jp/alt-quinon/files/NWPro/find/UseSelectionForFindAttributes_nwm.zip

Edit: Near the end of the macro, I added
Code:
Menu ':Format:Language:Any Language'
because I noticed that, without it, the macro does not work in one of my documents (formatted e-text).


2009-04-08 05:16:17
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software