Call-by-reference problem again

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

Hi,

I modified my code, I’m afraid that I can’t find it. It is like the
following:

class MailInfo
def initialize
@path=@recipients=@from=Array.new

end
def parse
case header
when “TO”, “CC”, “BCC”
@recipients << header
when “RECEIVED”
@path << header
end
end

end

in the above code, the arrays will interfere with each other. The way to
solve it is not to use chained assignment.

Thanks
Shannon

···

On Tue, 3 Dec 2002 07:10:30 +0900 William Djaja Tjokroaminata billtj@y.glue.umd.edu wrote:

Shannon Fang xrfang@hotmail.com wrote:

Hi Bill,
In my test the Arrays are all pointing to the same object, but the
strings are not. I now understand that david has explained what happed
in my prog.

Hi Shannon,

Can you give me the code where arrays are behaving differently from
strings?

Bill

Yes, because they are all the same array :slight_smile:
But why is it any different from String(s)?

···

On Tue, Dec 03, 2002 at 08:18:39AM +0900, Shannon Fang wrote:

Hi,

I modified my code, I’m afraid that I can’t find it. It is like the
following:

class MailInfo
def initialize
@path=@recipients=@from=Array.new

end
def parse
case header
when “TO”, “CC”, “BCC”
@recipients << header
when “RECEIVED”
@path << header
end
end

end

in the above code, the arrays will interfere with each other. The way to
solve it is not to use chained assignment.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Linux - Das System fuer schlaue Maedchen :wink:
– banshee