MathGroup Archive 2001

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

Search the Archive

Carriage Return oddity in Mathematica

  • To: mathgroup at
  • Subject: [mg31199] Carriage Return oddity in Mathematica
  • From: "Eric Stiers" <ewstiers at>
  • Date: Wed, 17 Oct 2001 05:35:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


I recently found what seems to be an unusual 'interpretation' of a carriage
return character by Mathematica. My goal is to develop a way to monitor the
progress of a large matrix as the elements are being calculated. To this end
I tried to get Mathematica to print the column and row of each element as it
is completed. For the first try, the code (simplified here) and the output
looked something like this:

Foo = Table[Part[{F[nx,nz], Print[nx, ",", nz]}, 1], {nx, 0, 3}, {nz, 0,




And so on...

The problem was that the real matrix had many elements, so the number of
output lines quickly got into the thousands. A better approach would seem to
be to use the 'WriteString' function, since it doesn't append a carriage
return/linefeed to the end of each line. Then by adding just a carriage
return (with no line feed) to the end of the string, the output should
re-write itself over and over again on the same line. Sadly, this didn't

Foo = Table[
      Part[{F[nx,nz], WriteString[$Output, nx, ",", nz,
        1], {nx, 0, 3}, {nz, 0, 3}];



where FromCharacterCode[13] is the command to add an ASCII character 13,
i.e. a carriage return. The form of the output seems to indicate that
Mathematica considers a carriage return, which normally instructs a computer
to return the cursor to the beginning of the current line, to somehow also
imply a line feed - a movement of the cursor down one line. In traditional
computing these functions have usually be separate, and a CR/LF combo was
needed to start a new line.

So Mathematica seems to have a different interpretation of the carriage
return character than most other programming environments. That's fine,
however the question remains: is there any way to get a 'pure' carriage
return effect (i.e., move to the beginning of the same line but don't add a
line feed) in Mathematica?

All suggestions will be greatly appreciated!

Eric Stiers
ewstiers at

  • Prev by Date: Re: Sorting and Selecting in MultiLevel Lists?
  • Next by Date: Re: fonts
  • Previous by thread: Re: fonts
  • Next by thread: Re: Carriage Return oddity in Mathematica