Macro for e-mail style quotes

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
maurerc
Posts: 46
Joined: 2003-04-28 07:19:23

Macro for e-mail style quotes

Post by maurerc »

Does anybody have a macro to convert a block of text to e-mail-style quotes?
hatchmo
Posts: 99
Joined: 2004-03-01 10:35:56
Location: Cotati, CA

Post by hatchmo »

Just download SmartWrap http://www.selznick.com/products/smartw ... /index.htm.

I tried to write my own Perl macro, but this little program is so good and so flexible, it made more sense to spend the $18 on it.

What the company's website doesn't tell you is that, once you've installed SmartWrap, it's available in every application on your drive. It appears in the Services menu. That means it works on selected text in NWX or in your email program. Sweet.
Al Hatch
maurerc
Posts: 46
Joined: 2003-04-28 07:19:23

Post by maurerc »

This removes quotes but I want to add them. Am I missing something?
Steve
Posts: 17
Joined: 2004-11-11 08:58:19

Post by Steve »

Do you mean changing text like

Did you see the movie

to

> Did you see the move
maurerc
Posts: 46
Joined: 2003-04-28 07:19:23

Post by maurerc »

Yes, with lines wrapped to fewer than 80 characters.
Steve
Posts: 17
Joined: 2004-11-11 08:58:19

Post by Steve »

I'm not a perl person -- this is my second Macro so take it with a grain of salt. I'm sure the xperts can do this better, but it might be of some use... Note that the formatting is changed in posting, but just figure that everything that starts with a '#' is a comment (the top from #Nisus Macro Block to #End Nisus Macro Block has to remain).

#Nisus Macro Block
#source clipboard
#destination clipboard
#Before Execution
#Clipboard 1
#Copy
#After Execution
#Paste
#Clipboard 0
#End Nisus Macro Block

# PURPOSE
# To take text in Nisus Writer Express and quote it like an emailer.
# The lines are not to be longer than 80 chars long (see below -- the
# lineLength and the quoting char can be changed)

# USE
# In NWE, Select whatever text one wants to have quoted, then activate
# this macro from the Macro menu. If one wants a different quote char/string
# than the one provided -- '>', then change the $quoteChar variable. To
# change the line length, change the $maxLineLen value.

# NOTES:
# 1) we don't do any error checking. i.e., what happens
# if the line is one whole word longer than 80 chars?
# The next line is printed with the entirety of the 80+ characters

# DISCLAIMER
# I program in Objective C, C, and C++. I don't do Perl. But this seems
# to do what is needed. Modify or throw out as you see fit.

my $quoteChar = ">"; # change for different quote char
my $maxLineLen = 80; # change for different line length

while (my $sentence = <>) # get a line from the clipboard
{
chomp($sentence); # get rid of the terminating newline

print "$quoteChar "; # print our first quote thingy
my @words = split(/ /, $sentence); # break line up into words

# set up some of our variables
my $lineLen = 0; # keep track of how long our line is
my $wordLen = 0; # length of current word
my $numWords = scalar @words; # how many words?
my $wordNum = 0; # count iterator of words

# loop through each word. check to see if we can add it to
# the line. If we can't (because it would make the line too long
# then we should start a new line by printing the newline and our
# quote thingy. Otherwise, print out the word
# and increment our variables. Note we need to account for the spces
# between the word, so we add 1 to the length of the word.
while ($wordNum < $numWords)
{
$wordLen = length(@words[$wordNum]) + 1; # don't forget the spaces
if ($lineLen + $wordLen > $maxLineLen)
{
print "\n$quoteChar "; # start a new line
$lineLen = 0; # remember to reset our line length
}

print @words[$wordNum], " ";
$wordNum++;
$lineLen += $wordLen;
}
print "\n";
}
Last edited by Steve on 2004-11-14 18:49:08, edited 1 time in total.
hatchmo
Posts: 99
Joined: 2004-03-01 10:35:56
Location: Cotati, CA

Post by hatchmo »

maurerc wrote:This removes quotes but I want to add them. Am I missing something?
Yes, you are. It doesn't just remove quotes, it reformats whatever you've selected any way you want. The preferences enable you to specify something to place at the beginning of every line after it has been wrapped. That might be a caret (>), "REM" statement, or just a 10-space indent. If you'd like your text to be hard-wrapped to 40 characters per line and indented 2 spaces with an asterisk, that's up to you.
Al Hatch
maurerc
Posts: 46
Joined: 2003-04-28 07:19:23

Post by maurerc »

Thanks to both of you. Steve, I ran your macro and get a series of errors that are logged as:

2004-11-15 18:54:56.208 Nisus Writer Express[5750] No menu item for Path: Copy
2004-11-15 18:54:56.209 Nisus Writer Express[5750] No menu item for Path: Copy ...
2004-11-15 18:54:56.209 Nisus Writer Express[5750] No menu item for Path: Copy …
2004-11-15 18:55:02.852 Nisus Writer Express[5750] No menu item for Path: Paste
2004-11-15 18:55:02.852 Nisus Writer Express[5750] No menu item for Path: Paste ...
2004-11-15 18:55:02.852 Nisus Writer Express[5750] No menu item for Path: Paste …

Also, whenever I open NWE, and often after it is open, I see these errors in the log:

2004-11-15 18:44:20.059 Nisus Writer Express[5748] No menu item for Path: :Format:Plain Text
2004-11-15 18:44:20.059 Nisus Writer Express[5748] No menu item for Path: :Format:Use Default Formatting
2004-11-15 18:44:20.060 Nisus Writer Express[5748] No menu item for Path: :Format:Increase Indent
2004-11-15 18:44:20.060 Nisus Writer Express[5748] No menu item for Path: :Format:Decrease Indent

Can somebody from Nisus please explain what is going on?
cchapin
Posts: 424
Joined: 2004-02-25 18:28:40
Location: Nagoya, Japan

Post by cchapin »

Regarding the errors you got when you run Steve's macro, I tried it and got something similar. I edited the macro and added the full "menu path" for the commands that were flagged. So Copy became Edit:Copy:Copy, etc. That seemed to fix things. See if it works for you.

Thanks for the macro, Steve.

--Craig
Steve
Posts: 17
Joined: 2004-11-11 08:58:19

Post by Steve »

Hi Craig.

Thanks for figuring that out. I couldn't see what the problem might have been, but I've only been at this NWE thing for about a week so my legs aren't quite under me yet :) Gotta admit, though, it's a lotta fun just knowing that my MS Word is gathering neutrino dust now that I've got NWE.

Later,
STeve.
Post Reply