Looking into Steve's code we see it cheats. Our problem has been that the 
Julia console output does not appear on STDOUT, only the results of print() 
do. Steve's code evaluates the input expression and then prints it. What we 
see in STDOUT is not the Julia console output, but results of "println("RESULT 
= ", result)". We can have this effect without an infinite loop, what I 
ended up using during the last couple of days:
const STDOUT_orig = STDOUT

function evalh(s::String) # paste to console: evalh("""<Julia commands> 
""")\n
try
rd,wr = redirect_stdout()
s = eval(Base.parse_input_line(s))
close(wr) # needed for readall()
s = readall(rd) * (s == nothing ? "" : string(s))
catch s
finally
redirect_stdout(STDOUT_orig)
end
clipboard(s) # return result/error-message
end

Reply via email to