# StringForm and NotebookWrite

I'm trying to get my head around NotebookWrite for the last few days. I can't understand why

NotebookWrite[nb,
Cell[
StringForm["some text = ", 3]
, "Text"
]]


doesn't seem to produce what I would expect:

some text = 3

in the newly defined notebook nb.

Why is this? How can this be achieved? Thanks all, once again!

-
This is not a problem of NotebookWrite but of Cell with StringForm. Check out Cell-s documentation under Details and "The contents of cells can be the following". As you will see, StringForm is not listed, so you either have to convert it to a normal string (e.g. using ToString@3) or to some xxxData object. –  István Zachar Sep 8 '13 at 7:33

Istvan Zachar's comment is correct, but I think it does not cover your main confusion. The key observation here is that even though it seems like your StringForm expression evaluates to a string, it actually gets displayed that way by front end. To see what the expression looks like to Mathematica, you can do

StringForm["some text = ", 3] // FullForm


which just gives

(*output*)
StringForm["some text = ",3]


So Mathematica sees this expression with head StringForm, rather than a string. So if we do for example

Head[StringForm["some text = ",3]]


we get StringForm, whereas if we do

Head["some text = 3"]


we get String.

Note that it is possible to use ToString on an expression with Head StringForm to get a real String. Also, as mentioned in another answer of mine in a question of yours, you should considered using boxes rather than just strings inside your Cell's

Closely related: how to convert string output into executable commands

-
Thanks for the comment, I'll take a look a the link! –  Gabriel Sep 13 '13 at 13:43