Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Multiple Selections in Notebook

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65220] Re: Multiple Selections in Notebook
  • From: "David Reiss" <dbreiss at gmail.com>
  • Date: Sat, 18 Mar 2006 06:40:43 -0500 (EST)
  • References: <dv8vqf$ng9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Neal,

Here is one strategy for a function that will do what you want.  (Then
number string "578208455191942" is just a random tag).

The function uses the Kernel exclusively.  It can probably be rewritten
to work using only the FrontEnd.

Thanks for this question.  I think that I may include this function in
the New Mathematica Package that I am in the midst of finishing off....
  but of course it's yourse for the using....

Best,

David




(* **************************** *)

CelarAll[EvaluateToHere];

EvaluateToHere::usage = "EvaluateToHere[nb] evaluates all Input cells
in
    the notebook nb up to and including the current selection in nb. \
EvaluateToHere[] does this or the current InputNotebook. ";

EvaluateToHere[nb_NotebookObject] :=
    Module[{hasTag, selection},

      SelectionMove[nb, After, Cell, AutoScroll -> False];

      NotebookWrite[nb, Cell["", "Input", CellTags ->
{"578208455191942"}, CellOpen -> False]];

      SelectionMove[nb, Before, Notebook, AutoScroll -> False];

      selection = NotebookFind[nb, "Input", Next, CellStyle, AutoScroll
->
       False];

      hasTag = MemberQ[Flatten[{CellTags /.
        Options[selection]}], "578208455191942"];


      While[! hasTag,

        SelectionEvaluateCreateCell[nb];

        selection = NotebookFind[nb, "Input", Next, CellStyle,
AutoScroll -> False];

        hasTag = MemberQ[Flatten[{CellTags /. Options[selection]}],
"578208455191942"];

        ];

      NotebookFind[nb, "578208455191942", All, CellTags];

      NotebookDelete[nb]


      ];

EvaluateToHere[] := EvaluateToHere[InputNotebook[ ]]

(* **************************** *)







Neal Tornberg wrote:
> I'd like to create an "Execute to Here" button in one of my homebrew
> palettes.  My instinct is to do it by selecting all cells previous to the
> cursor position and "Evaluate Cells".  SelectionMove apparently can't be
> made to select more than one cell at once.  Is there a way to do that or is
> there a better way to accomplish what I want?


  • Prev by Date: Re: Different font behavior between kernel and front-end
  • Next by Date: Re: Is this a BUG of D[f, var1, ..., NonConstants -> {u1, ...}] ?
  • Previous by thread: Multiple Selections in Notebook
  • Next by thread: ScatterPlot3D with One More Dimension?