MathGroup Archive 2004

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

Search the Archive

File reference in Front End

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49043] File reference in Front End
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Tue, 29 Jun 2004 04:50:26 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Mathgroup friends,
I have a Front End problem, which someone might be able to solve for me. How
do I by Front End programming get the notebook object corresponding to a
filename? I want to make a button with ButtonEvaluator -> None, which make
SubsessionEvaluateCells on cells in another open notebook, and I want to
refer to that open notebook by the filename in the ButtonFunction. How do I
do that?

To simplify things, I have defined a button that just moves the selection
one step down in another notebook (with notebook object number 14). This
button works in the desired way:

CellPrint[
  Cell[BoxData[
      TagBox[ButtonBox["movedown",
          ButtonFunction :>
            FrontEndExecute[
              SelectionMove[NotebookObject[$FrontEnd, 14], Next, Cell]],
          ButtonEvaluator -> None, Active -> True], DisplayForm]], "Output",
    CellLabel -> "Out[2]//DisplayForm="]]

The object number can be obtained by the Kernel command

Notebooks["Example.nb"][[1, 2]]

If I only specifies Notebooks["Example.nb"], a list containing the notebook
object is returned. I cannot use the same command in the Front End, since
Part it not defined there, and I have to extract the information from the
list. (Apply does not work either.) I do not want to use the notebook object
number, since that is redefined in each new session, and I would prefer to
be able to reuse the buttons without regenerating them for every new
session. So I want NotebookObject[$FrontEnd, 14] to be replaced by something
else, containing the filename. Is that possible?

When I have tried to solve this problem myself, I have looked at the Front
End commands (complementary to the Front End Tokens), given by

Names["FrontEnd`*"]

Some (most?) of these 66 commands are undocumented (In the Mathematica book,
in 2.11.5 the following informative comment is made: "But it turns out that
the front end is set up to execute a limited collection of commands
directly, without ever involving the kernel".) In connection to my question,
do you know what "FrontEnd`NotebookOpenReturnObject" is doing?
What are the arguments for this command? (I did a Google search on
"NotebookOpenReturnObject", and found my own mathgroup posting [mg47734]...)

On my wish list for a better Mathematica there is one point about better
documentation of the Front End tokens. Another point is that basic commands
for controlling the flow of programs should be implemented in the Front End.
Thanks in advance,

Ingolf Dahl
Sweden


  • Prev by Date: RE: one question about draw graph in frame
  • Next by Date: RE: one question about draw graph in frame
  • Previous by thread: Re: Appropriate codec for playing Mathematica generated .wav files
  • Next by thread: Palettes on a Mac Help