How do i open a notebook from mathlink (python)
- To: mathgroup at smc.vnet.net
- Subject: [mg39761] How do i open a notebook from mathlink (python)
- From: anand at calbay.com (Anand)
- Date: Thu, 6 Mar 2003 02:36:01 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I am trying to open a notebook using mathlink. I downloaded pyml
and build the ML.pyd file to communicate with mathlink. i have the
sample output and the sample code below
==================================================================
output
===============
C:\Alpha TTx Test Software\Test Executioner V1.0\Source\Python>python
mathtalk1.py
instance of mathematica ready
--------------------------------------------------------------------------------
InputName: text= In[1]:=
--------------------------------------------------------------------------------
$Aborted
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
$Aborted
--------------------------------------------------------------------------------
C:\Alpha TTx Test Software\Test Executioner V1.0\Source\Python>
======================================================================
source code
======================================================================
#### Example code for usage of PYML
##
from Mathematica import *
##
#### wrap the function in an expression and evaluate it
def evaluate(function):
print "-" * 80
expression = MathematicaExpression(function)
## print "Expression:"
## print expression
e = m.evaluate(expression)
## print "-" * 80
## print "Result:"
result= m.process()
## print
print "-" * 80
print result
print "-" * 80
print
if __name__ == '__main__':
##
#### Instantiate Mathematica; start the MathLink kernel
m = Mathematica()
print "instance of mathematica ready"
NotebookOpen = MathematicaFunction("NotebookOpen")
function = NotebookOpen("\"c:\\a.nb\"")
evaluate(function)
NotebookGet = MathematicaFunction("NotebookGet")
func = NotebookGet("c:\\a.nb")
evaluate(func)
#### Shut down the kernel
m.finish()
=========================================================================
How do i open the note book? the pyml and mathlink dll were written
for mathematica v 3.2. Has anyone doen this before?
thanks in advance
Anand.