Thanks, Steve. Good to know that something works under MacOS. 
Unfortunately, I get nothing to the Windows clipboard with your 2-engine 
method, which was the problem that started this thread. (Also, my 
application does not need an infinite Julia loop: I can just surround the 
code to be executed with output redirection Julia commands - if ever they 
would work.)

On Thursday, July 3, 2014 2:48:57 PM UTC-6, Steven G. Johnson wrote:
>
> It works for me on MacOS.  e.g. putting the code below into a file 
> capture.jl, then running
>       julia capture.jl
> I can then type e.g. display("foo") and "foo" gets included in the text 
> copied to the clipboard.
>
> #####################################################
> const orig_STDOUT = STDOUT
> rdstdout, wrstdout = redirect_stdout()
> pushdisplay(TextDisplay(STDOUT))
>
> while true
>     try
>         result = eval(Base.parse_input_line(STDIN))
>         println("RESULT = ", result)
>     catch e
>         print("EXCEPTION = ")
>         Base.showerror(STDOUT, e)
>     end
>     s = readavailable(rdstdout)
>     clipboard(s)
>     print(orig_STDOUT, s)
> end
>
>

Reply via email to