MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Create a notebook with both input and output cells

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117272] Re: Create a notebook with both input and output cells
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Sun, 13 Mar 2011 05:28:09 -0500 (EST)

You could do something like:

doc = CreateDocument[{}, DefaultNewCellStyle -> "Input"];
NotebookWrite[
  doc, {"a=3", "b=4", "a^2+b^2", "Plot[Sin[x],{x,0,\[Pi]}]"}];
FrontEndTokenExecute[doc, "EvaluateNotebook"];

Heike

On 12 Mar 2011, at 10:07, Alexei Boulbitch wrote:

> Dear community,
> 
> When one creates a notebook using CreateDocument, one gets the new 
> notebook with only output cells. For example, executing the simple code 
> below:
> CreateDocument[{
>   a = 3, b = 4,
>   a^2 + b^2,
>   Plot[Sin[x], {x, 0, \[Pi]}]
>   }]
> 
> one makes a document with 4 cells containing the outputs: 3, 4, 25 and a 
> sinus graph.
> 
> My question: is it possible to programmatically open a new notebook with 
> some content, such that both input cells will be there? In the example 
> given above it should look like the following:
> 
> a = 3
> 
> 3
> 
> b = 4
> 
> 4
> 
> a^2 + b^2
> 
> 25
> 
> Plot[Sin[x], {x, 0, \[Pi]}]
> 
> the sinus graph that I do not copy to save place.
> 
> 
> Thank you, Alexei
> 
> -- 
> Alexei Boulbitch, Dr. habil.
> Senior Scientist
> Material Development
> 
> IEE S.A.
> ZAE Weiergewan
> 11, rue Edmond Reuter
> L-5326 CONTERN
> Luxembourg
> 
> Tel: +352 2454 2566
> Fax: +352 2454 3566
> Mobile: +49 (0) 151 52 40 66 44
> 
> e-mail: alexei.boulbitch at iee.lu
> 
> www.iee.lu
> 
> --
> 
> This e-mail may contain trade secrets or privileged, undisclosed or
> otherwise confidential information. If you are not the intended
> recipient and have received this e-mail in error, you are hereby
> notified that any review, copying or distribution of it is strictly
> prohibited. Please inform us immediately and destroy the original
> transmittal from your system. Thank you for your co-operation.
> 
> 



  • Prev by Date: Re: Problems Using Mathematica
  • Next by Date: Re: Execute on notebook creation
  • Previous by thread: Re: Create a notebook with both input and output cells
  • Next by thread: Problems Using Mathematica