Hi,
I wonder if someone knows how to program such a macro: one that converts each comment to an inline comment of this type:
This is the referring text [This is the comment I added to this text, PT].
Author's abbreviation would be optional; automatic highlight (optional) would be very highly appreciated.
Uh, and the other way round (from inline comments to NW comment) would also be nice...
(Sooner or later, I'll learn how to program...)
Cheers,
Paolo
Converting comments to inline comments
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Converting comments to inline comments
Hi Paolo, here's a macro for you:
It doesn't insert the initials of the authors, which I don't think is currently possible, but it does highlight the comments. You'll notice I used double brackets to [[surround]] the comments, so that the inverse macro doesn't slurp up all bracketed text. But perhaps that's not necessary for you.
Here's the inverse:
There is one possibly significant limitation: the revived comments will all be marked as if they had been created by the current author (ie: the author running the macro).
Code: Select all
Select Document Start
$count = 0
While true
# move to the next comment, detecting if no more comments
$previousSelection = TextSelection.active
Menu 'Go to Next Comment'
$selection = TextSelection.active
If $selection.range == $previousSelection.range
Break
End
# save the comment, remove it, and place it inline
$comment = Read Selection
Menu 'Remove Comments in Selection'
Select End
Type Text ' [['
Insert Attributed Text $comment
Menu 'Highlight:Yellow'
Select End
Menu 'Highlight:Remove Highlight Attribute'
Type Text ']]'
$count += 1
End
Prompt "Converted $count comments to be inline."
Here's the inverse:
Code: Select all
Select Document Start
$count = 0
# scan for comments enclosed in double brackets
While Find Next ' \[\[(?<comment>.+?)\]\]', 'E$'
# delete the inline comment and add back in the normal comment
Delete
Menu 'Add Comment'
Insert Attributed Text $comment
# remove highlight
Menu 'Highlight:Remove Highlight Attribute'
Menu 'Paragraph Style:Comment'
$count += 1
End
Prompt "Found and converted $count inline comments."
Re: Converting comments to inline comments
The second macro does not work for me. Inline comments are just deleted..
Re: Converting comments to inline comments
I'll try these macros later today. In the meantime, thank you very much Martin, these promise to be real time-savers. Good idea to avoid using square brackets. I could eventually replace the double square brackets with a brace.
Paolo
Paolo
Re: Converting comments to inline comments
OK, tested both macros (after adapting them to the Italian version). They seem to work fine.
I'll post both the English and the Italian version in the Macro forum.
Thank you Martin!
Paolo
I'll post both the English and the Italian version in the Macro forum.
Thank you Martin!
Paolo
Re: Converting comments to inline comments
That was in Draft View.Hamid wrote:The second macro does not work for me. Inline comments are just deleted..
In Page View the macro works fine.
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Converting comments to inline comments
That's odd, that shouldn't make a difference. I just tested it and you're right, the macro doesn't work in Draft view. For some reason the "Add Comment" macro command doesn't move the focus/selection to the comment area in Draft View. I'll have a look at fixing this.Hamid wrote:That was in Draft View.Hamid wrote:The second macro does not work for me. Inline comments are just deleted..
In Page View the macro works fine.
Here's a revised macro that functions both in Draft View or Page View:
Code: Select all
Select Document Start
$count = 0
# scan for comments enclosed in double brackets
While Find Next ' \[\[(?<comment>.+?)\]\]', 'E$'
# delete the inline comment and add back in the normal comment
Delete
Menu 'Add Comment'
# in Draft View the Add Comment command doesn't move focus to the comment area; fix that
$selection = TextSelection.active
If 'comment' != $selection.text.documentContentType
Menu 'Go to Comment Text'
End
# insert comment text and remove highlight
Insert Attributed Text $comment
Menu 'Highlight:Remove Highlight Attribute'
Menu 'Paragraph Style:Comment'
$count += 1
End
Prompt "Found and converted $count inline comments."
Re: Converting comments to inline comments
Martin, may I ask you to move this discussion to the Macro forum? I would prefer to avoid duplicates, and I did the mistake to start it in the wrong one.
Thanx, Paolo
Thanx, Paolo
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Converting comments to inline comments
Sounds like a good idea to me- topic moved, thanks Paolo.