The following creates a button to select a notebook to run. When the button is pressed it seems that Mathematica finds the notebook but cannot evaluate it. The following error occurs

Could not process unknown packet "1"

Button["run file 1", 

This occurs under Mathematica 8 on all platforms.

Any help greatly appreciated, Christina

  • 1
    $\begingroup$ Does using Button[..., Method->"Queued"] help? $\endgroup$ – celtschk May 22 '12 at 17:08
  • $\begingroup$ Please evaluate this (and press the button) and report the result: Button["run file 1", TracePrint @ NotebookEvaluate[ "/../file1.nb"]] $\endgroup$ – Mr.Wizard May 22 '12 at 17:10
  • $\begingroup$ Also, please try a fully qualified path name, e.g. "C:/User/Notebooks/file1.nb" or whatever. $\endgroup$ – Mr.Wizard May 22 '12 at 17:11
  • 2
    $\begingroup$ Button[..., Method->"Queued"] worked. Many thanks celtschk and @Mr.Wizard $\endgroup$ – Christina May 22 '12 at 17:26
  • $\begingroup$ @celtschk please post that as an answer, or I shall. Christina, glad you've got it working! $\endgroup$ – Mr.Wizard May 22 '12 at 17:32

To make it work, use

Button["run file 1", NotebookEvaluate["/../file1.nb"], Method->"Queued"]

In the comments celtschk suggested Button[..., Method -> "Queued"] and Christina confirmed it as a solution.

  • 1
    $\begingroup$ @Christina does Button["run 1", NotebookEvaluate["/../file1.nb"]] also work by itself? $\endgroup$ – Mr.Wizard May 22 '12 at 16:50
  • 1
    $\begingroup$ Great question @Mr.Wizard. It doesn't, I get the same error, so my question should actually be "How do I make NotebookEvaluate work inside Button?" I can't believe I didn't test that. $\endgroup$ – Christina May 22 '12 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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