Re: ScientificForm with NotebookWrite
- To: mathgroup at smc.vnet.net
- Subject: [mg20531] Re: ScientificForm with NotebookWrite
- From: "P.J. Hinton" <paulh at wolfram.com>
- Date: Sat, 30 Oct 1999 00:13:51 -0400
- Organization: "Wolfram Research, Inc."
- References: <7v3dvc$64m@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 26 Oct 1999, Steve wrote:
> I'm a newbie flying by the seat of my pants and can't figure out how
> to get a value to be displayed in scientific notation that is being
> written to a notebook using Mathematica 3.0.
>
> I am "piping" selected results to a summary notebook by way of the
> following commands.
>
> nb=NotebookCreate[];
>
> $DisplayFunction=((NotebookWrite[nb,
>
> Cell[GraphicsData["PostScript",DisplayString[#]],"Graphics"]];#)&);
>
> $Post=(If[#=!=Null,NotebookWrite[nb,Cell[BoxData[MakeBoxes[#]],"Output"]]])&;
>
> and
>
> NotebookWrite[nb,{sse},Before]
>
> These commands work fine and place the value of sse (and other values
> and grapics) where I need them.
>
> The problem is that sse gets written as a 16 decimal placed value and
> I need scientific notation.
>
> I tried
>
> NotebookWrite[nb,{ScientificForm[sse]},Before]
>
> and
>
> NotebookWrite[nb,ScientificForm[sse],Before]
>
> without much luck; I get a box form error.
>
> What's particularly baffling here to me is that ScientificForm[expr]
> works fine if I don't pipe it to the summary notebook.
>
> Can someone help me with this syntax ?
Convert the formatted result of ScientificForm to a box structure and
place it in an inline cell. This produces nice looking results that fit
in with the flow of text
With[
{sse = N[E^5]},
NotebookWrite[
EvaluationNotebook[],
Cell[
TextData[
{
"The approximate value of \[ExponentialE] rasied to the fifth power \
is ",
Cell[
BoxData[
ToBoxes[ScientificForm[sse, 6], TraditionalForm]
]
]
}
],
"Text"
]
]
]
--
P.J. Hinton
Mathematica Programming Group paulh at wolfram.com
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.