MathGroup Archive 2001

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

Search the Archive

Re: Carriage Return oddity in Mathematica

In a message dated 2001/10/17 7:33:05 AM, ewstiers at writes:

>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
>progress of a large matrix as the elements are being calculated. To this
>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
>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
>line feed) in Mathematica?

(* This will write to a single line in a separate notebook *)

nb = NotebookCreate[];

      NotebookWrite[nb, "Row "<>ToString[nx]<>", Column "<>ToString[nz]]; 
      SelectionMove[nb, All, Cell];

Bob Hanlon
Chantilly, VA  USA

  • Prev by Date: Re: Sorting and Selecting in MultiLevel Lists?
  • Next by Date: eulers and modified eulers
  • Previous by thread: Carriage Return oddity in Mathematica
  • Next by thread: Switching x and y axes in 2D plots