Reply to topic  [ 3 posts ] 
Select by Style macro 
Author Message
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
The following macro is a little demonstration of the increasing power of Nisus' macro language. A long time ago Kino wrote a series of macros to do "Select by" for various properties including styles. (I believe these may be supplied among the standard set in the "Find" folder.)

They are certainly nice macros, but they are not for the faint of heart. Here is an attempt to rewrite the "Select by Style" macro using some of the new features in NWP. The most important is the ability to do Find using a Style object as the find expression. This makes the macro a lot shorter :wink:

Attachment:
Select By Style (new).nwm [18.1 KiB]
Downloaded 213 times


And this brings me to a feature request: it would be nice if the same could be done with Attributes objects. And how about being able to use style or attributes as replace arguments as well (in which case they would apply the style/attributes to the found selections)?

_________________
philip


2013-11-13 08:06:03
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Quote:
They are certainly nice macros, but they are not for the faint of heart.

That's certainly true! Kino is very clever and accomplished great things using macros, but had to manage quite a bit of complexity to achieve his goals.

Quote:
Here is an attempt to rewrite the "Select by Style" macro using some of the new features in NWP. The most important is the ability to do Find using a Style object as the find expression. This makes the macro a lot shorter :wink:

Ah, wonderful– much cleaner! I especially enjoy seeing the use of the "getProperty" command to dynamically loop through the different style types.

Quote:
And this brings me to a feature request: it would be nice if the same could be done with Attributes objects. And how about being able to use style or attributes as replace arguments as well (in which case they would apply the style/attributes to the found selections)?

It sounds like a good idea to me, I'll file the suggestion. Thank you Philip.


2013-11-13 23:12:22
Profile WWW
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
martin wrote:
I especially enjoy seeing the use of the "getProperty" command to dynamically loop through the different style types.

Yes, it was great to find a use for that :)
There are a couple of other interesting commands in Nisus' macro language. My favorite is .arrayByMakingValuesDoCommand which I now try to use at every opportunity. :P For example here is a truly barebones version of the select by style macro (which dispenses with the fancy interface altogether):
Code:
$doc = Document.active
$styleNames = $doc.allStyles.arrayByMakingValuesDoCommand 'name'
$styleName = prompt Options 'Choose a style', '', 'Find', $styleNames
$style = $doc.styleWithName($styleName)
Find All $style

_________________
philip


2013-11-14 00:36:24
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software