Transpose Words Applescript

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
landi3337
Posts: 18
Joined: 2004-11-17 11:37:25

Transpose Words Applescript

Post by landi3337 »

In the ancient days, WordPerfect had a "transpose words" command, where you put the cursor between two words, hit the command, and the two words would swap places.

Does anyone know of a Perl or Applescript that would do this in NWE? I've been messing with Applescript for hours, but can't get it to do this simple command.
Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

I played a bit with the 'swap columns' macro and came out with something that looks like working: You have to select the two words before you activate this macro:

#Nisus Macro Block
#source front selection
#destination front selection
#End Nisus Macro Block
use strict;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

my $text;
while (my $words = <STDIN>) {
chomp($words);
$words =~ s/([^\s]+)\s([^\s]+)/\2 \1/;
print "$words";
}


Please check it to see whether it works in all conditions, as it is a first iteration..
gemboy27
Posts: 355
Joined: 2003-09-30 21:33:58

cool

Post by gemboy27 »

Thanks, but I have to say, as much as I like the idea of transposing words, I find that the step of highlighting the two words is the added step that makes it easier (for me) to double click on a word, then click a gain and hold down for a second and then dragging the word to the place I want to.

This is coming from sone one who used the transpose word function in PerfectWriter (on a Kayproo II) a couple thousand times. With that you just put the cursor between two words and hit control-shirt T... I don't know why, but that is easier than the macro and 'menu key' function

<a href="http://librarymonkey27.wordpress.com/fi ... kdance.gif" target="_blank"><img src="http://librarymonkey27.wordpress.com/fi ... kdance.gif" border="0" height="69" alt="monkdance.gif" /></a>

and of course I can spend an hour making a monkey dance...

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