Macros in 2.5

Have a problem? A question? This is the place for answers from other Express users.
WattsM
Posts: 40
Joined: 2003-11-13 13:50:17
Location: San Jose, CA
Contact:

Macros in 2.5

Post by WattsM »

Just out of curiosity, have there been any changes to the macro capability in 2.5? I know in an earlier message, it was suggested that you want to make it work with all shell languages (Ruby, Python, etc.) as well as expanding the AppleScript dictionary.

As I recall, the Perl macros didn't work completely as documented as it was in 2.1, and a way to more gracefully handle formatted text would still be nice. :)

(I haven't used NWX in a bit, but that's because I haven't been doing much word processing in a bit -- it's still my favorite word processor on OS X.)

gemboy27
Posts: 353
Joined: 2003-09-30 21:33:58
Contact:

creating Macros

Post by gemboy27 »

How difficult is it to write a script or macro

I would like to have a script that transposes words

so you would have

tired dog

and the macro would make it

dog tired

thanks
I have never let my schooling interfere with my education/Mark Twain (1835-1910)

MacSailor
Posts: 290
Joined: 2003-04-03 08:38:41
Location: Linköping, Sweden

Re: creating Macros

Post by MacSailor »

gemboy27 wrote: I would like to have a script that transposes words
Or why not a script that transposes letters as in old NW. I hope it's not rocket science. ;-)
Peter Edwardsson
..............................

gemboy27
Posts: 353
Joined: 2003-09-30 21:33:58
Contact:

Re: creating Macros

Post by gemboy27 »

MacSailor wrote:
gemboy27 wrote: I would like to have a script that transposes words
Or why not a script that transposes letters as in old NW. I hope it's not rocket science. ;-)
how about this, is there a site that shows how to make macros, so I can try to figure out how to transpose words or characters?

gm 27
I have never let my schooling interfere with my education/Mark Twain (1835-1910)

cgc
Posts: 80
Joined: 2004-09-19 13:30:46
Location: California
Contact:

Re: creating Macros

Post by cgc »

gemboy27 wrote:How difficult is it to write a script or macro

I would like to have a script that transposes words

so you would have

tired dog

and the macro would make it

dog tired

thanks
How often do you do this? Just curious...

gemboy27
Posts: 353
Joined: 2003-09-30 21:33:58
Contact:

is once a day enough

Post by gemboy27 »

I don't know, it isn't a daily thing, because my bigger writing projects come all at once, then it is four or five times a day, especially when it comes to transposing characters

I use the quick fix to automatically change 'teh' to 'the'

I guess I try to type fast and the results is the need to transpose...

why do you aks ;-)
I have never let my schooling interfere with my education/Mark Twain (1835-1910)

midwinter
Posts: 333
Joined: 2004-09-09 18:07:11
Location: Utah
Contact:

Re: is once a day enough

Post by midwinter »

gemboy27 wrote: I use the quick fix to automatically change 'teh' to 'the'
You don't even have to do that. On OS X, cntrl-t will reverse two letters. If you type "teh," just stick the cursor between the "e" and the "h" and press cntrl-t. The two letters will be transposed.

gemboy27
Posts: 353
Joined: 2003-09-30 21:33:58
Contact:

thanks

Post by gemboy27 »

for the common ones it is good to have a quick fix

hmmm where can you get a list of those OSX tricks

??
I have never let my schooling interfere with my education/Mark Twain (1835-1910)

cgc
Posts: 80
Joined: 2004-09-19 13:30:46
Location: California
Contact:

Re: is once a day enough

Post by cgc »

gemboy27 wrote:I don't know, it isn't a daily thing, because my bigger writing projects come all at once, then it is four or five times a day, especially when it comes to transposing characters

I use the quick fix to automatically change 'teh' to 'the'

I guess I try to type fast and the results is the need to transpose...

why do you aks ;-)
I write a lot as well and never transpose words, characters may get transposed at a rate of one per month...just curious. Thnaks. :)

midwinter
Posts: 333
Joined: 2004-09-09 18:07:11
Location: Utah
Contact:

Re: thanks

Post by midwinter »

gemboy27 wrote:hmmm where can you get a list of those OSX tricks

??
You know, I can't remember where I picked that one up. It's just one of those things...like holding down the command key and moving windows in the background or using keyboard shortcuts (cmd-W, cmd-O, cmd-M, cmd-shift-A/H/C, etc.)


You might try MacOSXHints.

riccardo
Posts: 15
Joined: 2005-05-30 09:09:28
Location: Maine

Missing an integrated macro language

Post by riccardo »

One of my disappointments with Nisus Writer Express is that is doesn't have it's own macro language. Nor is there much documentation about how to use perl with Nisus (sheesh! I have to learn yet another programming language?! -- I just want to get some writing chores done!).

I've only come over to the Mac since OS X, so I never had the fortune to use the old Nisus, but apparently it had its own killer macro language that was fully integrated into (old) Nisus' commands and so on -- much like VBA works in Word. Right? So why can't we have something like that for NWE? Using a general purpose programming/scripting language to write NWE-specific macros sounds like a real kludge to me. What do the macro aces think about this? Am I missing something?

dshan
Posts: 334
Joined: 2003-11-21 19:25:28
Location: Sydney, Australia

Re: Missing an integrated macro language

Post by dshan »

riccardo wrote:One of my disappointments with Nisus Writer Express is that is doesn't have it's own macro language. Nor is there much documentation about how to use perl with Nisus (sheesh! I have to learn yet another programming language?! -- I just want to get some writing chores done!).

I've only come over to the Mac since OS X, so I never had the fortune to use the old Nisus, but apparently it had its own killer macro language that was fully integrated into (old) Nisus' commands and so on -- much like VBA works in Word. Right? So why can't we have something like that for NWE? Using a general purpose programming/scripting language to write NWE-specific macros sounds like a real kludge to me. What do the macro aces think about this? Am I missing something?
But if NWX had it's own scripting language you'd still have to "learn another programming language": NWX's language. Using Perl means leveraging a language that's public, open source, has a large and flexible set of text manipulation facilities and is already familiar to many people. It makes much more sense than creating yet another proprietary "Nisus-only" scripting language users have to learn just for NWX. Applescript is also available and, aside from not being open source, has much the same advantages as Perl -- lots of users already know it. Using pre-existing widely used scripting languages like Perl and Applescript instead of reinventing the wheel is the macro equivalent of using RTF as the file format -- it doesn't lock you in.

People keep saying that there's not much info on writing Perl macros for NWX but there's actually quite a lot: the NWX User Guide explains the architecture, macro directives and what they do, how to invoke existing macros from your macro, etc. Then there's a bunch of supplied Perl macros that you can examine and modify to your heart's content. There's links to Perl courses and docs you can use to learn Perl and find out what text manipulation commands it has and what you can do with them.

dshan
Posts: 334
Joined: 2003-11-21 19:25:28
Location: Sydney, Australia

Re: creating Macros

Post by dshan »

gemboy27 wrote:How difficult is it to write a script or macro

I would like to have a script that transposes words

so you would have

tired dog

and the macro would make it

dog tired

thanks
Here's a NWX Perl script that transposes selected words as requested:

#Nisus Macro Block
#source clipboard
#destination clipboard
#before execution
#Copy
#after execution
#Paste
#End Nisus Macro Block

while (my $line = <>) {
my @wordArray = split(" ", $line);
print join(" ", reverse(@wordArray));
}

Unfortunately it adds an extra space to the end of the transposed text when it pastes it back into the document from the clipboard but I seem to recall that's a known issue with Paste in NWX 2.1.x (I haven't tried 2.5b, hopefully it's fixed there).

I wrote the above macro today, having virtually zero knowledge of Perl when I started, using the documentation in the NWX User Guide, a course -- "Practical Perl Programming" -- I found at: www.cs.cf.ac.uk/Dave/PERL/perl_caller.html
and looking at some of the Perl macros that come with NWX.

The point is that it's really not that hard to write simple NWX macros, even if you don't know Perl, using the NWX documentation and public Perl resources. It does help to have used other programming/scripting languages such as C, Java, Javascript, Tcl, csh or bash, etc. before though. If you've never programmed before it'd be considerably more difficult I imagine.

gemboy27
Posts: 353
Joined: 2003-09-30 21:33:58
Contact:

wow!

Post by gemboy27 »

thank you for the script

and thank you for the link

if anyone wants to use it, you have to highlight both words. And it doesn't add the space

it is fun

tired dog tired dog

becomes

dog tired dog tired


not to mention
tired dog becomes dog tired


yes, thanks again
I have never let my schooling interfere with my education/Mark Twain (1835-1910)

Jzents
Posts: 48
Joined: 2005-08-03 12:17:16
Location: USA

Speaking of the space

Post by Jzents »

I have some macros that I wrote to add "canned" comments to papers I am grading. I do not want them to add a space in front of the pasted text, but they do. Does anyone know a trick to make that stop or is that the bug reappearing in a new place.
Jeffrey Zents
jzents@mac.com

Post Reply