Timeline for Controlling output of graphics, the role of ";" and code structure/formatting
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 24, 2014 at 15:02 | comment | added | Julian Moore | @AlbertRetey Again, thanks. At the moment Mma feels like a 10000 page jigsaw puzzle and these insights are slowly helping me organise the pieces. Some apps I have worked with since their inception, and their quirks, foibles and evolutionary legacies are now second nature to me. Mma will eventually become familiar, I expect. | |
Mar 24, 2014 at 14:26 | comment | added | Albert Retey |
... instead of Print[Show[g]]; you could also use Show[g,DisplayFunction->Print]; but I don't think that is very enlightning...
|
|
Mar 24, 2014 at 14:24 | comment | added | Albert Retey |
Print prints to $Output , an the usual frontend environment that will create a new output cell (actually a cell with style "Print"). Print will also work when used on the command line, there Print will really print to "stdout". DisplayFunction I consider a leftover from pre-version-6 area: The display of a graphics in a notebook then was a side effect. DisplayFunction was a possibility to do interfere with that process, e.g. suppress rendering altogether. Its main value with newer versions probably is when working without a frontend...
|
|
Mar 24, 2014 at 14:13 | comment | added | Julian Moore | @AlbertRetey. Hmmm... I see that as Print refers to \$Output, Show refers to \$DisplayFunction... so if Print is pointing to a file, and Show is e.g. a PopupWindow, what happens? Anyway, quirk in the highlighting it is... this beginner did spend rather too much time trying to find a synatx error though! | |
Mar 24, 2014 at 14:10 | comment | added | Julian Moore | @Kuba, thanks for the expert perspective: the documentation doesn't seem to say anything about a Compound Expression needing to be wrapped and the basic examples suggest otherwise! As for Print to Stdout - I see: I might Print to a file. Per Print documentation though, does that mean that if $Output is not Stdout then it would not "generate a cell styled print"? If so, the documentation could be clearer... | |
Mar 24, 2014 at 14:05 | comment | added | Kuba |
and if your Shows are CompoundExpressions I'd do (a; Return[b, CompoundExpression]; c;) , if you really can't put it in a separate line.
|
|
Mar 24, 2014 at 13:58 | comment | added | Albert Retey |
I think the recommended way is to use Print[Show[...]]; per line. Unlike Print , Show has no side effects (at least not since the major changes in how graphics are handled in version 6). The magenta highlighting doesn't really indicate a syntax error, I'd rather consider it an error in the highlighting. If you find that highlighting irritating you could put the ; after the comment, add another ; after the comment or explicitly put Null after it. As documented a;b; is actually CompoundExpression[a,b,Null] ...
|
|
Mar 24, 2014 at 13:57 | comment | added | Kuba |
1) Print[expr] is different than expr , evaluation will send expr via Print to $Output . 2) If you have a; , b , c; in consecutive lines in the cell then only b will be printed. It is not a CompoundExpression unless you wrap it with something, e.g: (a; b c;) (each in new line) Take a look at first part of this answer too.
|
|
Mar 24, 2014 at 13:27 | history | asked | Julian Moore | CC BY-SA 3.0 |