MathGroup Archive 2005

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

Search the Archive

Re: Controlling Print[].

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54102] Re: Controlling Print[].
  • From: "Jose M. Martinez" <martinez at cs.utwente.nl>
  • Date: Thu, 10 Feb 2005 02:47:38 -0500 (EST)
  • Organization: University of Twente, The Netherlands
  • References: <cu78se$m8e$1@smc.vnet.net>
  • Reply-to: martinez at cs.utwente.nl
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Josef,


Here there is another way to carrying out the printing process...

If you want to keep track of your progress, for example, printing some values
you can inspect later, and you don't want to overload your current notebook,
what you can do is to open another notebook and send the information to print
there:


(* ... Open new Notebook (with some options)... *)

nb = NotebookCreate[WindowSize -> {500, 400}, StyleDefinitions -> "Notepad.nb",
    WindowTitle -> "Work In Progress", WindowToolbars -> "None",
    FontColor -> Red, FontWeight -> "Bold"];

(* ... Main Loop: printing iteration number and time ... *)

Do[
    i++;
    If[Mod[i, 10000] == 0, NotebookWrite[nb, Cell["Iteration: " <> ToString[i]
       <> "    Time: " <> ToString[Date[][[{4, 5, 6}]]], "Output"]]
    ];,
    {i, 1000000}
]


(* ... Close Notebook (if you want)  ...*)

NotebookClose[nb];





Regards,

   Jose M. Martinez


Josef Karthauser wrote:
> Dear anyone know a way of controlling Print[]?  I've got a large loop
> that I want to keep tabs on, and see how quickly it is running.  Within
> one of the inner loops I'm doing something like 'a // Print' where 'a'
> is some kind of location indicator.  This is fine in principle, but in
> practice the inner loop runs lots of times and so I get a single output
> box per time (several pages).  What I would like to do is have them
> printed one after another on the same line, i.e
> 
>     for(i = 0; i < 1000; i++) {
> 	printf("%d ", i);
>     }
> 
> instead of
> 
>     for(i = 0; i < 1000; i++) {
> 	printf("%d\n ", i);
>     }
> 
> Is this kind of thing possible?  I can imagine constructing a string in
> the loop and then printing that, but that wouldn't give the desired
> affect because it would effectively behave like buffered output; what I
> want is unbuffered, i.e. print the variable to the current output box,
> but don't finish it yet as the next output also want to go here.
> 
> Joe
> --
> Josef Karthauser (joe at tao.org.uk)	       http://www.josef-k.net/
> FreeBSD (cvs meister, admin and hacker)     http://www.uk.FreeBSD.org/
> Physics Particle Theory (student)   http://www.pact.cpes.sussex.ac.uk/
> ================ An eclectic mix of fact and theory. =================


  • Prev by Date: Re: problem with FindRoot
  • Next by Date: Re: NDSolve and differential equation system
  • Previous by thread: Re: Controlling Print[].
  • Next by thread: Pseudodecahedron