Re: call notebook
- To: mathgroup at smc.vnet.net
- Subject: [mg61850] Re: call notebook
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Tue, 1 Nov 2005 00:39:58 -0500 (EST)
- References: <dk4dh9$s28$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Ravi Purandare wrote: > Hi. How are you? I was looking for a way to call a notebook file in MATHEMATICA as you would call a subroutine or function in a programming language. My problem is I would like to have a loop structure containing many cells. I found one way by having a conditional Evaluate Notebook command at the end of a notebook file creating a loop and I know that the Do command can contain multiple sub-commands in a single cell but these approaches seem messy. Let me know. Thanks. > Hello, Cells don't really execute in loops at all. Typically, each cell in a program executes once, however if a cell defines something - such as a function - that function might subsequently get called many times. For example, suppose you had the following two cells (which might exist in different notebooks): f[i_] := Print[i]; Do[f[k], {k, 10}] Executing the first cell would define a function f, and executing the second cell would call the function f for values 1 through 10. The body of the Do could, of course be more complicated and call function f1,f2,f3,etc. I hope this helps a bit, but I would also try working through a lot of examples from the book to get a better grasp of what Mathematica is doing. David Bailey http://www.dbaileyconsultancy.co.uk