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:
Tue, 4 Jan 2011 23:40:27 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (117 lines)
Hello Kino,

Thank you very much for your reply.

On Jan 2, 2011, at 2:23 AM, Kino wrote:

>> can I understand that they are somehow equivalent of "SetSelect  
>> (x, y)" in Classic Nisus Writer macro...?
>
> I have a vague feeling that your very long acquaintance with NW  
> Classic macro -- much longer than mine -- tends to mislead you. NWP  
> macro has nothing to do with NW Classic macro although you may  
> believe to see something common, accidentally.

Well, I mentioned this (possible...) "equivalence" only as an  
analogy, just because it seems to me easier to understand the NWP  
macro language by analogy with the Classic Nisus Writer macro  
language. But I understand that in fact they are very different in  
nature.

To return to the my question about "SetSelect"..., the macro below  
will show you what I wanted to know:

### begin macro ###

$doc = Document.active
$paraStarts = $doc.text.findAll '^', 'E', '-am'

$sels = Array.new
foreach $start in $paraStarts
	if $start.text.documentContentType == 'body'
		$sel = TextSelection.new $start.text, $start.range
		$sels.appendValue $sel
	end
end

$tab = Cast to String "\t"
foreach $i, $start in reversed $sels
	$num = $i + 1  # $i: index number
	$num &= $tab
#	$doc.setSelection($start)
#	Type Text $num
#	exit
	$start.text.insertAtIndex $start.location, $num
#	exit
end

### end macro ###

If I use

	$doc.setSelection($start)
	Type Text $num

instead of

	$start.text.insertAtIndex $start.location, $num

I think this would be very close to the Classic Nisus Writer Macro  
which would be:

Find All "^." "gAa-S"
s -> push (Starts)
ct = NumFound

loop:
	Clipboard = ct + NumToChar (9)
	the_start = s -> pop
	SetSelect (the_start, the_start)
	MacroPaste
	if (s -> size == 0) Exit
	ct = ct - 1
GoTo loop

(As my machine still allows the Classic environment, I could test  
this macro, and it works...).

In Classic Nisus macro language, it was the line

	s -> push (Starts)

which seemed (to me...) strange, difficult to understand, almost a  
magic. But otherwise, it was rather easy to understand, because, I  
think, all was done, so to speak, in the screen: we could always  
follow the location of the insertion point (or selection), and  
verify, if we wanted, where it was. We could control the location of  
the insertion point with "SetSelect (x, y)", and know what would be  
inserted with "MacroPaste"...

What is difficult in the new NWP macro language (for me) is that this  
pattern of thinking is no longer (really) valid. I understand that

	$start.text.insertAtIndex $start.location, $num

does the same thing as

	$doc.setSelection($start)
	Type Text $num

but even if we stopped the macro just before  
"$start.text.insertAtIndex $start.location, $num", we don't see where  
the insertion point is... But this is certainly the reason why the  
new NWP macro is much faster than the Classic NW macro (because it  
does not "move" the insertion point).

But now, I seem to begin to understand a little better how the new  
macro works.

Anyway, I will have to work much longer to begin to be a little  
familiarized with it.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

ATOM RSS1 RSS2