Hi,
I’m attempting to map output of a ‘system’ call
directly in to an FXText window.You might want to take a look at the inputs.rb example program that
comes with FXRuby, although I’m not sure how well it’s going to work
on Windows. There is a (non-FXRuby related) problem with doing
non-blocking file I/O on Windows and I’m not sure that it has been
resolved yet.
Sorry, but not yet.
IO multiplexing on pipes doesn’t work under Windows since
select() in WinSock nor WaitFor*Object(s) don’t support
pipes. Now I wonder there’s no other way except for native
threads…
I’ve been looking for ways to change $stdout or
something so that whatever the seperate app generates,
it actually just goes straight to the window.
You may be possible to take “tail -f” approach.
NOTE: untested
require ‘tempfile’
redirect to a temporary file
begin
tmp = Tempfile.new(‘foo’)
saveout = STDOUT.dup
STDOUT.reopen(tmp)
f = IO.popen(‘foo.exe’, ‘w’) # system cannot run child
# process asynchronously.
ensure
STDOUT.reopen(saveout)
saveout.close
end
Thread.new do
begin
# read output while the process is running
until Process.waitpid(f.pid, Process::WNOHANG)
sleep 1
myTextBox.appendText(tmp.read) # read new data all
foo.seek(0, IO::SEEK_CUR) # clear EOF flag
end
ensure
tmp.close(true)
end
end
textBoxStream = IO.new($stdout.fileno,“w”)
def textBoxStream.putc(char)
myTextBox.appendText(char)
end
Overridden #putc doesn’t work as event callback.
···
At Thu, 28 Nov 2002 08:36:49 +0900, Lyle Johnson wrote:
At Thu, 28 Nov 2002 07:21:23 +0900, Jason Persampieri wrote:
–
Nobu Nakada