6
$\begingroup$

Thanks to this great topic, I've found the FrontEndToken that I was looking for: "DeleteGeneratedCells" (well, it is also written in Help but I've found it later :)

Question: I would love to execute it in NotebookObject without confirmation through the automatically displayed ChoiceDialog["Do You really want to..."].

Is it maybe a case of FrontEndTokenExecute parameters?

I suspect I can deal with it by setting some global options for Mathematica but I would rather leave them.

$\endgroup$
2
  • 1
    $\begingroup$ Related, perhaps duplicate: How to automate a FrontEnd return? $\endgroup$ Sep 12, 2013 at 11:52
  • $\begingroup$ @IstvánZachar I would say it is very closely related because our purposes are a bit little different and acceptable solutions too. But we will see what community decides ;) $\endgroup$
    – Kuba
    Sep 12, 2013 at 11:55

1 Answer 1

10
$\begingroup$

Maybe you are looking for something like this. Make a list of the generated cells like this:

cells = Cells[GeneratedCell -> True];

Then delete them from the notebook using this

NotebookDelete[cells];
$\endgroup$
4
  • $\begingroup$ I had to check but it seems that for my needs this works well. And there is no ChoiceDialog[] so thank You for this answer :) $\endgroup$
    – Kuba
    May 21, 2013 at 18:16
  • $\begingroup$ @Kuba no problem, glad you like it :) $\endgroup$ May 21, 2013 at 18:17
  • 3
    $\begingroup$ I'm very happy to see answers using the under-utilized Cells function. But I'm not sure what you mean by your statement that this "doesn't use the front end". Both Cells and NotebookDelete require a front end to work properly, and they're implemented by causing the kernel to issue commands to the front end. Incidentally, code very similar to this is in the Applications Examples section of the Cells documentation. $\endgroup$
    – John Fultz
    Sep 12, 2013 at 5:48
  • $\begingroup$ @JohnFultz ah, yes, I have made this mistake in another Q&A as well, and fortunately there I was immediately corrected. I should have remembered this Q&A. Thank you $\endgroup$ Sep 12, 2013 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.