MathGroup Archive 2001

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

Search the Archive

RE: Execute a Menu Item

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29153] RE: [mg29139] Execute a Menu Item
  • From: Mikael Adlers <mikael at mathcore.com>
  • Date: Fri, 1 Jun 2001 04:15:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
it is possible to execute menu commands by sending a token to the FrontEnd.
This can be done using the function FrontEndTokenExecute[String]. The next
step
is to figure out what token to send. The configuration of the menus can be
found in the text file MenuSetup.tr.

On my system (windows) this file is found in,
C:\Program Files\Wolfram
Research\Mathematica\4.0\SystemFiles\FrontEnd\TextResources\Windows\

Searching the file we find the following,
Item["De&lete All Output", "DeleteGeneratedCells"]

The second string is the token, thus

FrontEndTokenExecute["DeleteGeneratedCells"]

should do the trick. (Unfortunately a dialog will be displayed and
the used has to press the ok button to remove the cells)

Another way to remove is to use the following script:

nb = EvaluationNotebook[]
SelectionMove[nb, Before, Notebook, AutoScroll -> False];
SelectionMove[nb, Next, Cell, AutoScroll -> False];

(* A cell from the kernel will have the option GeneratedCell set to true *)
generated = Options[NotebookSelection[nb], GeneratedCell];

While[generated =!= $Failed,
  If[(GeneratedCell /. generated),
    NotebookDelete[nb]
    ];
  SelectionMove[nb, Next, Cell, AutoScroll -> False];
  generated = Options[NotebookSelection[nb], GeneratedCell];
  ];
SelectionMove[nb, Before, Notebook, AutoScroll -> False];

Regards,
/Mikael Adlers

------------------------------------------------------------------ 
 Mikael Adlers, Ph.D.          email: mikael at mathcore.com 
 MathCore AB                   phone: +4613 32 85 07 
 Wallenbergsgata 4             fax:         21 27 01
 SE-583 35 Linköping, Sweden                   



> -----Original Message-----
> From: Doug Pickering [mailto:Pickering at BrandonU.ca] 
To: mathgroup at smc.vnet.net
> Sent: den 31 maj 2001 05:28
> To: mathgroup at smc.vnet.net
> Subject: [mg29153] [mg29139] Execute a Menu Item
> 
> 
> Is it possible to execute a menu item from within a notebook 
> using a command?
> 
> In particular can I put something into the first cell of a 
> notebook that runs the menu item:  "Kernel - Delete all Output"  ?
> 
> Thank you,
> 
> 
> Doug Pickering
> Professor
> Dept of Mathematics and Computer Science
> Brandon University
> (204) 727-9674
> Pickering at BrandonU.ca
> 
> 


  • Prev by Date: RSA and Fixed Exponents
  • Next by Date: Uniquely Subtracting Elements in a Flat List
  • Previous by thread: Re: RSA and Fixed Exponents
  • Next by thread: Uniquely Subtracting Elements in a Flat List