MathGroup Archive 2008

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

Search the Archive

Re: use of a notebook inside another notebook

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94458] Re: use of a notebook inside another notebook
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Sun, 14 Dec 2008 07:35:57 -0500 (EST)
  • References: <ghr12c$8sj$1@smc.vnet.net>

salcedo at ugr.es wrote:
> Hi. I apologize since the question is surely stupid, but I could not
> find the answer in the Mathematica book.
> 
> The question is how can I get to execute the commands in notebook A
> (sequentially, in the same order they are in that notebook) when I am
> working in notebook B.
> 

Usually when people ask for this, they really need something else.

The best way to program in Mathematica, is to write function definitions 
in one or more notebooks that are triggered by one actual function call.

Thus, inside notebook A, you would encapsulate your current code in a 
function. At its crudest, this might be:

functionA[]:=Module[{},
........ All the code that you use at present ......
];

Executing notebook A once would simply pass that function definition to 
the kernel - not execute its contents.

Now, in notebook B, you can simply call functionA[] whenever you need it.

Although this will solve your problem, don't stop there. Think about 
using local variables, and passing information through arguments rather 
than global variables.

Once you learn to program that way, you will find that you can assemble 
large quantities of code without the variable names clashing all the time.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Aligning two PLots
  • Next by Date: Re: Tooltip[] ListContourPlot[] 6.0 vs. 7.0
  • Previous by thread: Re: use of a notebook inside another notebook
  • Next by thread: D