It is common question when I do something like
Do[
MyFunction; (*Complicated and Very long*)
Print["."] (*printed dot makes me know that an iteration has done*)
,{imax}]
I get many lines with dot and I want ONE progress bar line growing,
like
.........
but not
.
.
.
Is there any chance?
Thanks,
Andrey B.
> Does anybody know how to force Mathematica to put symbols in one
> continuous line by repeatedly call the operator (say Print[]). If we
> call Print["a"] twice - we get two lines, and I want one line "a,a"
> It is common question when I do something like
>
> Do[
> MyFunction; (*Complicated and Very long*) Print["."] (*printed dot
> makes me know that an iteration has done*) ,{imax}]
>
> I get many lines with dot and I want ONE progress bar line growing,
> like .........
Print[] puts its output on a separate line so the only way this will work
through a loop, is to print your line with increasing numbers of dots.
(
Print[StringJoin["." & /@ Range[#]]]
) & /@ Range[10];
Perhaps a better way might make use of the status bar. There's a detailed
post by Paul Abbot from a few years ago
(http://forums.wolfram.com/mathgroup/archive/1999/Feb/msg00351.html), and
another by Jens-Peer Kuska
(http://forums.wolfram.com/mathgroup/archive/2000/Nov/msg00056.html) that
will help.
Regards,
Dave
TableForm[Table[a, {10}], TableDirections -> Row]
Ο/Η Andrey B. έγραψε:
It is possible, but not straightforward. The following assumes you are using
the notebook frontend, not the pure kernel.
What would come closest to what you have in mind is to use CellPrint to
write a cell that is marked with a special CellTag. When you want to add a
point, you could use frontend programming to delete the old cell and write
a new cell with one point added. If you think that sounds complicated for a
simple task, I fully agree. The approach is something I would recommend
only if e.g. you want to show the progress in some kind of plot or more
complicated information which needs complex formatting.
If I have to give simple status like information I prefer to write it to the
statusline of the frontend, which after all is what the status line is for.
If you search the archives for WriteStatus you will find postings with
explicit code which does this.
Last but not least you could look into the GUIKit documentation which comes
with versions > 5.0 and contains examples of how to create a real status
bar window.
hth,
albert
Best regards
Ingolf Dahl
> -----Original Message-----
> From: Andrey B. [mailto:be...@gorodok.net]
> Subject: How to make a progress bar?
>
> Hello,
But the real powerful thing is to remember that Cells and Notebooks are
expressions that you can manipulate just as any other expression in
Mathematica.
So with this in mind here is a refined example that might get you
started along the path you want to go. First do something like this.
In one input Cell execute the following to create a cell with a
specific cell tag:
CellPrint[Cell[" ","Text",CellTags->"progress"]]
Now, in another cell in the same notebook, execute the following which
finds and then writes into the end of the text in the cell that was
created by executing the previous input line
Do[
Module[{nb},
nb=EvaluationNotebook[ ];
NotebookFind[EvaluationNotebook[ ],"progress",All,CellTags,
AutoScroll\[Rule]False];
SelectionMove[nb,After,CellContents,AutoScroll\[Rule]False];
NotebookWrite[nb, "x"];
Pause[1]
],
{i,1,15}]
Take a look at http://scientificarts.com/worklife for the sorts of
things you can do with notebook programming and a bunch of tools that
make some of it more accessible. (Shameless plug for a useful product!)