NISUS Archives

January 2011

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:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Date:
Wed, 5 Jan 2011 20:40:03 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (60 lines)
Hello Kino,

Thank you for your reply.

On Jan 5, 2011, at 3:01 AM, Kino wrote:

> Then, perhaps it might be helpful to know that, while Document  
> object, Text object and TextSelection object are essential for NWP  
> macro language (if we speak about manipulating text objects only,  
> ignoring Image object for example), Range.object and Character  
> Index are something secondary and made available just for  
> convenience, I guess. For example and roughly speaking,  
> 'TextSelection.setActiveRange $range' can be regarded as a kind of  
> shorthand, equivalent to...
>
> 	$doc = Document.active
> 	$text = TextSelection.activeText
> 	$sel = TextSelection.new $text, $range
> 	$doc.setSelection $sel
>

Sorry, I am unable to understand this. What is the value of  
"$range"...? And anyway, both "TextSelection.setActiveRange" and  
"TextSelection.new" require range object, don't they...?

>
> Then, the hierarchy of various kinds of objects would be
>
> 	Document object > Text object > TextSelection object (>  
> Range.object > Character Index)
>
> Perhaps it would be better (for [self-]educational purpose) to try  
> to write macros without using any Range.object and Character Index.  
> None of commands requiring them solely seems to be essential. None  
> of them is really indispensable, I think.
>
> And a yet another version of insert paragraph number macro.
>
> $prefix = Cast to String ''
> $suffix = Cast to String ".\t"
> $doc = Document.active
> $i = $n = 0
> while $i < $doc.text.length
> 	$n += 1
> 	$doc.text.insertAtIndex $i, $prefix.textByAppending($n, $suffix)
> 	$range = $doc.text.rangeOfParagraphAtIndex $i
> 	$i = $range.bound
> end

This is also a very clever macro. But it does use a range object,  
doesn't it...?

Thank you in advance for your further explanation.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

ATOM RSS1 RSS2