Page 1 of 1

Transpose Words Applescript

Posted: 2006-08-28 10:34:34
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.

Posted: 2006-08-28 12:37:41
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..

cool

Posted: 2006-08-28 14:47:32
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