Volume 9, Issue 3
Tricks of the Trade
In and Out
Download This Issue
Staff and Contributors
In and Out
Q: I am using the following code to automatically close my graphics groups.
The problem is that when I only generate a single cell, OpenCloseGroup will generate a beep. How can I prevent that beep or test if GeneratedCell selected a single cell or several cells?
A: John Fultz (email@example.com) answers: You can test if multiple cells have been selected using
If the length is greater than 1, then you can use the OpenCloseGroup token.
CellInformation is new to version 5 and is, in general, a very good way to test various properties of the selection without having to do a NotebookRead (which could get very expensive if you have a selection that consumes a lot of memory). CellInformation takes a notebook argument and returns a list of lists, one for each cell in the selection (only one if you have only selected a single cell or the content of a cell). Each list contains rules along with information about the object that is selected (similar to the way NotebookInformation works).
Of course, since this is part of the undocumented packet interface, we reserve the right to make changes to it. I hope to see this or something like it promoted to a documented function similar to NotebookInformation in the future.
About Mathematica | Download Mathematica Player
© Wolfram Media, Inc. All rights reserved.