Intro + Ruby* Macro Wrapper

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
victory
Posts: 1
Joined: 2006-12-23 22:31:17

Intro + Ruby* Macro Wrapper

Post by victory »

[* Ruby as in the language, not the characters ]<br>
Hello,<br>
This is my first post to these forums as a new NWE user. First off, I’d like to thank the staff of Nisus for creating such a fine app and for the wonderful attitude the company exhibits overall. (No, my only relation to Nisus is as a customer :-) )<br>
Like many of you, I came to NWE looking for an alternative to Word. Also like many of you, I did a feature/trial comparison among the various OSX word processing packages out there and found that NWE fit my needs the best.<br>
Three of the features that put NWE above the competition for me were: Extremely powerful searching (regex? In a WP app? Awesome!), the fact that it’s already a Universal Binary, and the Perl-based macros.<br>
...<br>
Now, while I <i>respect</i> Perl and <i>appreciate</i> the reasons why it was chosen as one of the native macro dialects, I do admit to wishing that one could also write NWE macros in Ruby, my current favorite language of choice...<br>
Well, now you can!<br>
As a modest gift to the NWE user community, I’d like to present a (somewhat hacky) wrapper macro I wrote that allows you to embed Ruby code inside of a Perl script. <br>
Huh?<br>
Basically you paste Ruby code into a 'wrapper' macro. When the macro is run, it causes Perl to launch the Ruby interpreter built into OSX and pipes your code and any selected text along with it. Not the most elegant way to have Ruby macros in NWE, but it seems to work fairly well and the core code in the wrapper is really only about 18 lines long.<br>
So for you NWE users who’ve wished for a way to write macros in Ruby (all three of you <grin>) here’s my template as well as a few other sample files and a few notes.<br>
<a href="http://www.flex.com/~victory/projects/n ... zip</a><br>
NOTE: Just a word of caution that pretty much seems to apply to all NWE Perl-script macros : Be extremely careful when working with these and other macro scripts if you aren’t that familiar with the language. It is entirely possible to <b>lock up</b> NWE by making a mistake in your Perl code, and rendering the app unresponsive except for a Force-Quit. Please save your work BEFORE trying these macros.<br>
Also, be aware that these macros are entirely of my own creation -- please don’t bother the Nisus staff if they aren't working -- I’m the one to blame.<br>
-- victory
Post Reply