Page 1 of 1

Simple Macro not working

Posted: 2011-07-01 12:07:26
by macduffee
Another InDesign Tagged Text issue.

I am working on a document and need to tag all instances of italic text. Using the Find/Replace dialog I have no problems:

Find: .+ (Font Face italic)
Replace: <cstyle:Italic>\0<cstyle:>

When I macroize I get this:

Find and Replace '.+', '<cstyle:Italic>\\0<cstyle:>', 'EauU' (.+ is italic.)

Have I done something wrong?

Running version 2.0

Thanks!

Duff

Re: Simple Macro not working

Posted: 2011-07-01 23:17:20
by phspaelti
What part of this result is bothering you? You are getting exactlly the result you should be getting. Is something not working?

Having said that, there are a few pecularities about the macroize feature.
One is the appearance of the double-backslash. This shouldn't affect the functioning of the macro, but I dislike it myself, and usually remove it (by hand).
Another problem that may occur, is that while the ".+" has italic on it, it may also take on other features, such as the paragraph style. If that happens the macro may no longer find all the instances you want. In that case you have to check the styles in the macro and remove the relevant -- or rather the irrelevant -- attributes. Note that the same will be true for the features that appear on the replaced string.

Re: Simple Macro not working

Posted: 2011-07-05 08:51:42
by martin
phspaelti wrote:Another problem that may occur, is that while the ".+" has italic on it, it may also take on other features, such as the paragraph style. If that happens the macro may no longer find all the instances you want.
This would be my guess too. Probably you pasted the macroized code into a document and it took on some ambient attributes. At the least, probably a paragraph style is in effect, eg: Normal.

Re: Simple Macro not working

Posted: 2011-07-11 13:36:59
by macduffee
Thanks for all the quick replies.
phspaelti wrote:What part of this result is bothering you? You are getting exactlly the result you should be getting. Is something not working?
I should have mentioned that the macroized version does not work.
Martin wrote:Probably you pasted the macroized code into a document and it took on some ambient attributes.
I am not pasting anything anywhere, I am clicking on "Macroize" ->"Save as Macro"-> then saving. If it is being pasted into a paragraph style it is by the program itself.

I should also mention that performing the same steps using font face bold will not macroize properly either.

Here is my entire macro that I use repeatedly for one of our clients. Each line was inserted using the macroize feature without fail, except the most basic one at the top.

Find and Replace '.+', '<cstyle:Italic>\\0<cstyle:>', 'EauU'
Find and Replace ' \n', '\n', 'Ea'
Find and Replace '(.+[[:digit:]]\\n)(.+\\n)\\n(.+\\n)\\n(.)', '\\1<pstyle:Devo Title>\\3<pstyle:Devo Todays>\\2<pstyle:Devo Scripture Left>\\4', 'Ea'
Find and Replace '(scripture left>.+)(\\n\\n)', '\\1\\n<pstyle:Text1>', 'Ea'
Find and Replace '(Text1>.+\\n)', '\\0<pstyle:Text2>', 'Ea'
Find and Replace '(scripture left>.+)(\\–)', '\\1\\n', 'Ea'
Find and Replace '(<cstyle:Italic>)(\\x0C)(<cstyle:>)', '\\2', 'Ea'
Find and Replace '([[:upper:]].+)(\\,\\s)(.+)(\\s)([[:digit:]]+)(\\,\\s)([[:digit:]][[:digit:]][[:digit:]][[:digit:]])', '<pstyle:Day>\\1\\n<pstyle:Devo Date>\\3\\n<pstyle:Date Number>\\5', 'Ea'
Find and Replace '\\n\\nPrayer\\:\\n', '\\n<pstyle:Devo Prayer>Prayer\\n<pstyle:Devo PrayerSection>', 'Ea'
Find and Replace '(PrayerSection>.+\\n)(\\n<cstyle:Italic>)', '\\1<pstyle:Devo Prayer2>', 'Ea'
Find and Replace '(Text1>)((?:\\b\\w+\\b)\\s(?:\\b\\w+\\b)\\s)', '\\1<cstyle:caps>\\2<cstyle:>', 'Ea'
ExportAsUNICODE-MAC

I have edited the macro file using the "remove attributes and styles" feature, then reapplied the italic font face to the .+ to no avail. So I don't think it is a paragraph style issue. One thing I cannot do while editing the macro file is select "any font size" or "remove font size attribute" as it is grayed out.

Have any of you tried to duplicate this problem? Obviously it has something to do with the attributes, if I remove the "u from the search parameters it finds everything.

Thanks for your help.

Duff

Re: Simple Macro not working

Posted: 2011-07-12 01:38:55
by phspaelti
macduffee wrote:Thanks for all the quick replies.
I should have mentioned that the macroized version does not work.
You did mention this. And I think we have narrowed 'doesn't work' down to an attribute problem. So I hope we can help you get to the bottom of this.
Martin wrote:Probably you pasted the macroized code into a document and it took on some ambient attributes.
I am not pasting anything anywhere, I am clicking on "Macroize" ->"Save as Macro"-> then saving. If it is being pasted into a paragraph style it is by the program itself.
Actually I don't understand how you are creating the macro you mention without any pasting. I use "Save as Macro" a lot, but it only allows you to save one line macros. So surely you must be pasting something together, no? :?

So for what it is worth, for me, if I make a macro like yours and do "Save as Macro", it works. The macro created for me does not have any paragraph styles, and the macro appears in a courier type font, 12 pt, English, but these 'visible' styles don't seem to have any effect on the finding.

What you should do is the following. Open the macro, place the cursor on one of the "Find" lines of the macro and check what types of styles it has applied. If for example the line has a paragraph style applied, this will cause interference. If that it is the case try removing the style. You may have to remove other things as well, for example a ruler, a font, etc. Remove everything except the Italic.

Alternately try posting your macro here. (I mean upload the macro file. Don't paste the code. Your code looks fine.) Then we can download it and try to find what the culprit is.

Re: Simple Macro not working

Posted: 2011-07-12 11:07:11
by martin
Yes, philip's request to attach the actual macro file (and not just paste the code) is exactly right. It's quite difficult to tell what's going wrong without being able to inspect the actual attributes you have in your file/code. It would also be helpful to have a small test target file where you expect the macro to do something but instead it fails.

Well, hopefully we can get this figured out.

Re: Simple Macro not working

Posted: 2011-07-29 10:01:35
by macduffee
OK, sorry it has taken me so long to get back to this. I was waiting for the October text to arrive so I could deal with it all at once.

Philip, for the string that I am having issues with I am not pasting, I am using the Save as Macro command. Yes, for the rest I must paste but I'm not having any problems with those strings.

For what it's worth, if I have to strip out hidden styles every time I use the Save as Macro feature something's wrong with a great program.

Here is a link to download a screen movie of how I'm creating the macro, the macro itself and the file I'm working on.

http://www.kpaftp.com:8080/ItalicTest

Thanks for all your help.

Duff

Re: Simple Macro not working

Posted: 2011-07-29 22:35:35
by phspaelti
Hello again,

I have downloaded your files and I even had a look at the movie. Well you are doing everything correctly. That is how it should work.

I have identfied the culprit that is preventing your macro from finding anything, and it is a ruler. I don't know how it got there, but if you remove it from the macro, the macro should work.

best
Philip

Re: Simple Macro not working

Posted: 2011-08-17 07:49:07
by macduffee
Philip,
You are right! That works. The only problem is that the ruler appears again after I have saved, quit and then reopen the macro. Not a big problem but perhaps a bug?

Thanks again for all your assistance.

Duff