6
$\begingroup$

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", 
     NotebookEvaluate[
      "/../file1.nb"]]

This occurs under Mathematica 8 on all platforms.

Any help greatly appreciated, Christina

$\endgroup$
5
  • 1
    $\begingroup$ Does using Button[..., Method->"Queued"] help? $\endgroup$
    – celtschk
    Commented May 22, 2012 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
    Commented May 22, 2012 at 17:10
  • $\begingroup$ Also, please try a fully qualified path name, e.g. "C:/User/Notebooks/file1.nb" or whatever. $\endgroup$
    – Mr.Wizard
    Commented May 22, 2012 at 17:11
  • 2
    $\begingroup$ Button[..., Method->"Queued"] worked. Many thanks celtschk and @Mr.Wizard $\endgroup$
    – Christina
    Commented May 22, 2012 at 17:26
  • $\begingroup$ @celtschk please post that as an answer, or I shall. Christina, glad you've got it working! $\endgroup$
    – Mr.Wizard
    Commented May 22, 2012 at 17:32

2 Answers 2

7
$\begingroup$

To make it work, use

Button["run file 1", NotebookEvaluate["/../file1.nb"], Method->"Queued"]
$\endgroup$
4
$\begingroup$

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

$\endgroup$
2
  • 1
    $\begingroup$ @Christina does Button["run 1", NotebookEvaluate["/../file1.nb"]] also work by itself? $\endgroup$
    – Mr.Wizard
    Commented May 22, 2012 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
    Commented May 22, 2012 at 16:56

Your Answer

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

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