Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

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

2 Answers 2

up vote 7 down vote accepted

To make it work, use

Button["run file 1", NotebookEvaluate["/../file1.nb"], Method->"Queued"]
share|improve this answer

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

share|improve this answer
1  
@Christina does Button["run 1", NotebookEvaluate["/../file1.nb"]] also work by itself? –  Mr.Wizard May 22 '12 at 16:50
1  
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. –  Christina May 22 '12 at 16:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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