NISUS Archives

August 2012

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Sat, 18 Aug 2012 16:53:40 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Hello Chuck,

I'm very sorry for being so late in reply.

I don't keep the original macro but I think the following will do the job.

Kino

--

### Reverse Names ###

# Works on non-contiguously selected text portions.

$doc = Document.active
if $doc == undefined
	exit 'No open document, exiting...'
end

$sels = $doc.textSelections
if ! $sels.firstValue.length
	exit 'Select "Thad Jones" or "Jones, Thad" before running the macro, exiting...'
end

foreach $sel in reversed $sels
	$converted = undefined
	$converted = $sel.subtext.findAndReplace '^(\p{Upper}[^,]+),\x20(\p{Upper}[^,]+)$', '\2\x20\1', 'E-i'
	if ! $converted
		$converted = $sel.subtext.findAndReplace '^(\p{Upper}[^,]+)\x20(\p{Upper}[\S&&[^,]]+)$', '\2,\x20\1', 'E-i'
	end
	if $converted
		$sel.text.replaceInRange $sel.range, $converted.subtext
	end
end

### end of macro ###



On 2011-09-22 [+0900 JST], at 6:55 AM, Chuck Suber wrote:

> With all the updating, I've lost the macro that reverses names.
> I want to change:  *Jones, Thad *to* Thad Jones*
> and to change: *Thad Jones* to *Jones, Thad*
> *
> *
> Thank you one and all. — Chuck
> *
> *
> -- 
> Chuck (a.k.a. Charles) Suber
> Charles Suber & Associates, Inc.
> 1750 St. Charles Ave. #607
> New Orleans, LA 70130
> voice 504-524-3087
> email [log in to unmask]

ATOM RSS1 RSS2