Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Virtual Book > Data Manipulation > Files, Streams, and External Operations > Splicing Mathematica Output into External Files >

Splicing Mathematica Output into External Files

If you want to make use of Mathematica output in an external file such as a program or document, you will often find it useful to "splice" the output automatically into the file.
Splice["file.mx"]splice Mathematica output into an external file named , putting the results in the file file.x
Splice["infile","outfile"]splice Mathematica output into infile, sending the output to outfile

Splicing Mathematica output into files.

The basic idea is to set up the definitions you need in a particular Mathematica session, then run Splice to use the definitions you have made to produce the appropriate output to insert into the external files.
#include "mdefs.h"

double f(x)
double x;
{
double y;

y = <* Integrate[Sin[x]^5, x] *> ;

return(2*y - 1) ;
}

A simple C program containing a Mathematica formula.

#include "mdefs.h"

double f(x)
double x;
{
double y;

y = -5*Cos(x)/8 + 5*Cos(3*x)/48 - Cos(5*x)/80 ;

return(2*y - 1) ;
}

The C program after processing with Splice.

Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF