51
MakeNotebook[] :=
    UseFrontEnd[
        Module[ {nb, nbobj},
            nb = NotebookCreate[] ;
            NotebookWrite[ nb, Cell[ "A Dynamically Created 
Notebook", "Title"]] ;
            NotebookWrite[ nb, 
                Cell[ "Converted to " <> $$button, "Subtitle"]] ;
            NotebookWrite[ nb, Cell[ "The date is " <> ToString[ 
Date[]], "Text"]] ;
            nbobj = NotebookGet[ nb] ;
            NotebookClose[ nb] ;
            nbobj]]
GeneralContent[ fmt_] :=
    Module[ {nbobj},
        nbobj = MakeNotebook[] ;
        UseFrontEnd[
            Switch[
                fmt,
                    "Notebook",  
                        {ToString[ nbobj, InputForm],
                                "application/mathematica"},
                    "PostScript",
                        {DisplayString[ nbobj, "EPS"],
                                "application/eps"},
                    "GIF",
                        {DisplayString[ nbobj, "GIF"],
                                "image/gif"},
                    _, "Unknown format"]
                ]]
In this example, one evaluation tests the variable $$button. If it has a value from activating one of the buttons in
the form, this is used to specify a return format type and passed to a function, GeneralContent. The Mathemat 
ica code  for this  function  is placed  into a separate  package  to be loaded  when  the variable  is set. GeneralCon 
tent calls a function that creates a very simple notebook, MakeNotebook. MakeNotebook generates a notebook
using  the  Mathematica  Notebook  API  and  the  J/Link  function  UseFrontEnd.  In  a  real  life  situation  a  more
interesting notebook would probably be generated. 
MSPReturn
 returns the representation  of the notebook to the
server  with  the  content  type.  This  is  then  returned  to  the  browser,  which,  if  suitably  configured,  will  deploy  the
necessary helper application.
In  a  more  advanced  example,  the  dynamically  generated  notebook  would  probably  use  information  sent  with  the
request from the client. 
If you wish to return special content and also set a filename to be used with this content, then you may wish to use
the three argument form of 
MSPReturn
. This is described in the 
MSP Function Reference
 section. 
Another way to set the content returned from an MSP script is to use 
MSPPageOptions
. The topic of returning
general content is discussed later.
 .
<





New Page 1








Home : About Us : Network : Services : Support : FAQ : Control Panel : Order Online : Sitemap : Contact : Terms Of Service

 

Our web partners:  Jsp Web Hosting  Unlimited Web Hosting  Cheapest Web Hosting  Java Web Hosting  Web Templates  Best Web Templates  Web Design Templates  Interland Web Hosting  Cheap Web Hosting  Filemaker Web Hosting  Tomcat Web Hosting  Quality Web Hosting  Best Web Hosting  Mac Web Hosting

 
 

Virtualwebstudio. Business web hosting division of Vision Web Hosting Inc. All rights reserved

Comcast Web Hosting