Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Executing an external notebook within another notebook

224 views
Skip to first unread message

Tugrul Temel

unread,
Oct 20, 2008, 9:10:19 PM10/20/08
to
Dear All,

Recently, the issue of executing a notebook within another notebook has
arised and I worked on that for sometime. My progress has been limited and
I am stuck at the following point.

1) I wrote a generic "Common.nb" including the general code that can be
executed using different data set.
2) I created another notebook "data.nb" retriving the data from Excel for
calculations using the codes from "Common.nb"
3) I only open the "data.nb" and use Needs[] command to bring "Common.nb"
to the current "nb" file, it gives a lot of errors.
4) If I only open the "Common.nb" and run it, it also gives errors.
5) However, if I open both "data.nb" and "Common.nb" and run them
separately (the order of execution does not matter), then both programs
run properly, giving the desired outcomes.
6) This shows that these two "nb" have somehow been linked to each other
without my intention.

I do not know where I mass up. Please help me.

Regards,
Tugrul


Szabolcs Horvat

unread,
Oct 22, 2008, 5:40:21 AM10/22/08
to

I am not sure why this happens, just a note about point 3:

You cannot use Needs to read in a notebook. Instead make the relevant
cells in common.nb initialization cells, and save the notebook.
Mathematica will offer to create an auto-save package for you (which
will be called common.m). Now you can use Get["common.m"].

Jens-Peer Kuska

unread,
Oct 22, 2008, 5:40:43 AM10/22/08
to
Hi,

and you are too lazy to put the Mathematica program code
in a package and to write

Get["thePackageWithAllTheCodeINeed.m"]

Nobody need to execute a notebook from an other, because
all other people are able to split code and data/documents.

Regards
Jens

Tugrul Temel

unread,
Oct 24, 2008, 2:37:00 AM10/24/08
to
Dear All,

Finally, following the suggestions of Horvat (thanks go to him and David
Park), I have solved the problem of executing an external notebook within
another notebook. For those who still wait for the answer to this problem I
am summarizing the main steps involved.

1) I strongly suggest to create a Mathematica Package (using BeginPackage[]
and EndPackage[] statement. This was the key for the solution to the
problem.

2) Once you create a package then you recall this package into the main
notebook using Get["filename`"].

3) Before you use the GET command, you should set the directory to the
directory where the package is.

In case you like to know more on this topic, you may write me.

Regards,
Tugrul

-----Original Message-----
From: Szabolcs Horvat [mailto:szho...@gmail.com]
Sent: Wednesday, October 22, 2008 11:41 AM
Subject: Re: Executing an external notebook within another
notebook

I am not sure why this happens, just a note about point 3:

0 new messages