No problem, though Steven's explanation and example are the right way to go 
of course. In fact, together with the discussion in this thread and 
re-reading the section on IO in the docs Julia's IO system is making a lot 
more sense now. Thanks everyone!

On Sunday, 29 June 2014 18:04:00 UTC+2, Laszlo Hars wrote:
>
> Thanks Mike, this would allow fixing the problem, that display results 
> don't appear in STDOUT. The help says:
>
>    Display "x" using the topmost applicable display in the display
>    stack, typically using the richest supported multimedia output for
>    "x", with plain-text "STDOUT" output as a fallback.
>
> Redefining display() with hard coded STDOUT as the first parameter could 
> be one way. Another is temporarily modify the "display stack", to put 
> STDOUT on the top.
>
> --- Can someone tell us how to do these correctly? (Base.display(x) = 
> println(x) seems to work reasonable well.)
>
> Now "only" the problem of catching syntax error messages remain
>
> On Sunday, June 29, 2014 5:24:35 AM UTC-6, Michael Hatherly wrote:
>>
>> This might not be the best way to do it, but the following has worked for 
>> me in the past.
>>
>> The output to the REPL is produced using display() (I think), so you can 
>> use the following to get the same kind of output as a string:
>>
>> julia> buf = IOBuffer();
>> julia> td = TextDisplay(buf);
>> julia> display(td, [1,2,3]);
>> julia> str = takebuf_string(buf)
>> "3-element Array{Int64,1}:\n 1\n 2\n 3"
>>
>> If some has a simpler version I'd be grateful to see it as well.
>>
>> -- Mike
>>
>> On Sunday, 29 June 2014 10:28:16 UTC+2, Stéphane Laurent wrote:
>>>
>>> These days I have experienced Yihui's runr package and this is indeed 
>>> not very satisfactory yet. 
>>> Do you know whether we can straightforwardly get in Julia, the console 
>>> output as a ready-to-print character string, for example here:
>>>
>>> *julia> [1,2,3]*
>>> *3-element Array{Int64,1}:*
>>> * 1*
>>> * 2*
>>> * 3*
>>>
>>>
>>> I'd like to get:
>>>  
>>>
>>> *"3-element Array{Int64,1}:\n 1\n 2 \n 3"*
>>>
>>>
>>>
>>>

Reply via email to