Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Cell["\<\ ... \>", ... ; TextData[...]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114790] Re: Cell["\<\ ... \>", ... ; TextData[...]
  • From: Derek Yates <yatesd at me.com>
  • Date: Fri, 17 Dec 2010 03:28:50 -0500 (EST)
  • References: <iecr3r$bnb$1@smc.vnet.net>

I did find a reference to this in some of the legacy Mathematica
(version 5.2) documentation.

2.8.7 Advanced Topic: Newlines and Tabs in Strings
http://reference.wolfram.com/legacy/v5_2/book/section-2.8.7

John Fultz mentioned that the kernel simply ignores the delimiters,
however I noticed that the kernel's interpretation of a raw string is
still affected. As he mentioned, it is essentially legacy, as the
front-end no longer inserts raw strings into cells the way the 5.2
documentation mentions, but you can still see the behaviour if you try
editing a Cell expression (Cell > Show Expression) as follows:

type a few characters (I entered qwerty) in an empty cell in the front-
end, and then do Cell > Show Expression, and you will see something
like this:
Cell[BoxData["qwerty"], "Input"]

replace it with:

Cell["qw
erty","Input"]

where you have put the new line in using the Return key. Now when you
revert the Show Expression, you will see

qw erty

in the cell.

If you edit the cell expression again so that it is
Cell["\<qw
erty\>","Input"]

Then you will see

qw
erty

in the cell.

Here is an excerpt from the documentation. Note that the example they
show does not work in new versions of Mathematica, but my example
above showed how to create it artificially.

"When you enter a long string in Mathematica, it is often convenient
to break your input across several lines. Mathematica will by default
ignore such breaks, so that if you subsequently output the string, it
can then be broken in whatever way is appropriate.

Mathematica ignores the line break and any tabs that follow it.
In[3]:=  "A string on
two lines."

Out[3]=  A string on two lines

There is no newline in the string.
In[4]:=  InputForm[%]
Out[4]//InputForm=
 "A string on two lines."

Input forms for strings:
"text"  line breaks in text are ignored
"\<text\>"  line breaks in text are stored explicitly as \n

Here Mathematica keeps the newline
In[5]:=  "\<A string on
two lines.\>"

Out[5]=
A string on
two lines

In InputForm, the newline is shown as an explicit \n.
In[6]:=  InputForm[%]

Out[6]//InputForm=
"a string on\ntwo lines."



  • Prev by Date: Re: VectorPlot on a Circle
  • Next by Date: Re: Cell["\<\ ... \>", ... ; TextData[...]
  • Previous by thread: Re: VectorPlot on a Circle
  • Next by thread: Re: Cell["\<\ ... \>", ... ; TextData[...]