Update 2008-07-02
i have been trying to script a mathematica notebook that I have created that creates documents. I found it not as straightforward as it seems.
I started with at test notebook:
My method of getting this scriptable was to save as a .m file.
Then edit it with notepad by removing some of the comments (* to this:
(* ::Package:: *)
(* ::Input:: *)
(*This is a comment.*)
(* ::Input:: *)
(*a = {1,2,3}*)
(* ::Input:: *)
Export[NotebookDirectory[] <> "test.gif",Plot[Sin[x],{x,0,10}]]
(* ::Input:: *)
Exit[]
(**)
Then run it from a batch file like this:
F:
CD "\2008\Mathematica Auto"
"C:\Program Files\Wolfram Research\Mathematica\6.0\math" <"F:\2008\Mathematica Auto\test.m"
When I ran this didn't work as I couldn't use NotebookDirectory so I had to make the directory explicit:
(* ::Package:: *)
(* ::Input:: *)
(*This is a comment.*)
(* ::Input:: *)
(*a = {1,2,3}*)
(* ::Input:: *)
Export["F:\2008\Mathematica Auto\test.gif",Plot[Sin[x],{x,0,10}]]
(* ::Input:: *)
Exit[]
(**)
And this did run although not very elegant and I don't have a solution for running complex notebooks yet. When you try and load a notebook Mathematica says it wants a front end. It may be easier to script this inside Mathematica front end.
No comments:
Post a Comment