Re: How to call a notebook via a mathlink connection
- To: mathgroup at smc.vnet.net
- Subject: [mg20995] Re: How to call a notebook via a mathlink connection
- From: paulh at wolfram.com (P.J. Hinton)
- Date: Thu, 2 Dec 1999 21:41:09 -0500 (EST)
- Organization: "Wolfram Research, Inc."
- References: <firstname.lastname@example.org>
- Sender: owner-wri-mathgroup at wolfram.com
In article <822hlo$7o2 at smc.vnet.net>, Rainer Schmid <schmid at tecmath.de> writes: >I've got following task to solve: I need to start a notebook from a C >program and execute a computation. The main problem is that it must be a >notebook. I have no problem to call a Mathematica package; but this won't do >it. > >Am I right that I need the frontend loaded to load a notebook? The kernel is >not enough? I tried to start the frontend with "linklaunch" and open a link. >The problem is that I can't send packets to the frontend. I tried to send >commands with FrontEndTokenExecute but I do not get any return-packets; >and I need the output of the notebook. > >from my application (and not vice-versa). I must get output from >Mathematica. I'm programming under Windows NT in C++. > >Any ideas what I can do? Why do you need work with the notebook directly Do you plan to have the notebook serve as a container of the results? It is possbile to read a complete notebook expression into the kernel, pattern match for all cells that have "Input" style and then evaluate the box forms. nbExpr = Get[< notebook file >] inputCells = Cases[nbExpr, Cell[_, "Input", ___], -1]; Map[ToExpression, inputCells] However, this can require huge amounts of memory for large notebooks. You may want to consider having the author of the notebook use the AutoGeneratedPackage feature (see recent posting here on similar topic) to export the Input cells as a package. You can then use Roman Maeder's NotebookLog.m package (found in ProgrammingInMathematica packages on the Mathematica CD) to generate an notebook version of the results of the calculations. -- P.J. Hinton Mathematica Programming Group paulh at wolfram.com Wolfram Research, Inc.