NISUS Archives

April 2016

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, 13 Apr 2016 00:18:26 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (78 lines)
Hello Philip,

Thank you very much for your prompt reply and your always helpful macros.

The one you wrote on the list is just what I wanted. I just need the simplest one.

The new macro language (which is now not so new...) is so difficult for me to just understand...!

Thank you very much again.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

> On Apr 12, 2016, at 5:39 PM, spaelti <[log in to unmask]> wrote:
> 
> Hello Nobumi,
> 
> here is the basic idea
> 
> # Select From Cursor To Bookmark
> 
> # Get the document and the selection
> $doc = Document.active
> $sel = TextSelection.active
> 
> # Ask the user to choose a bookmark
> $bms = $doc.allBookmarks
> $bmNames = $bms.arrayByMakingValuesDoCommand 'displayName'
> $choice = prompt options 'choose one', '', 'OK', $bmNames
> $i = $bmNames.indexOfValue($choice)
> 
> # Create a new selection that covers the current 
> # up to and including the bookmark
> $range = $sel.range.unionRange $bms[$i].markedTextRange
> $newSel = TextSelection.new $doc.text, $range
> $doc.setSelection $newSel
> # end of macro
> 
> Now here are the problems.
> 1. This will work fine if all bookmarks have unique names. But bookmarks are not required to have unique names, so if your document contains bookmarks with the same name, you could only select to the first one in the list. To make a robust macro would require something more elaborate. (I’d prefer not to have to do that. It’s a headache.)
> 
> 2. I made it select the bookmark and the current selection inclusive. This will work both if the bookmark is before the current selection or after.
> But maybe you only want to select up to, and not including, the current bookmark (but still include the current selection?). In that case you need to separate several cases:
> - If the bookmark is after the current location, select to the location of the bookmark
> - if the bookmark is before the current location, select to the bound of the bookmark
> and maybe the same for the current location. Depends what you want.
> Or maybe you only want to allow selection to following bookmarks. That would simplify the selection, but would require changing the part that asks the user to choose.
> 
> Maybe you can adjust the macro yourself. Otherwise let me know what you want.
> Best
> Philip
> 
> 
>> On 2016 Apr 12, at 10:13, Nobumi Iyanaga <[log in to unmask]> wrote:
>> 
>> Hello all,
>> 
>> I need a macro which would select the text from the current cursor position to a bookmarked position. As there may be many bookmarks in a document, I think the best way to do this would to display a list selecting window in which the names of bookmarks are listed -- so that I would be able to select the bookmark that I want, and select the text from the current cursor position to that bookmarked position.
>> 
>> Thank you very much in advance to anyone (Philip??) who would be so kind to write such a macro for me.
>> 
>> Best regard,
>> 
>> Nobumi Iyanaga
>> Tokyo,
>> Japan
> 
> Philip Spaelti
> [log in to unmask]
> 
> 
> 
> 
> 

ATOM RSS1 RSS2