print "Enter text: “
while gets
chomp!
puts ‘Got "’ + $_ + '”'
print 'Enter more: '
end
But running it in the SciTe 1.41 environment with Ruby 1.6.8, I get:
Enter text: IO_Test1.rb:2:in `gets’: Bad file descriptor
(Errno::EBADF)
I’ve asked about this before on this NG, but wonder if anybody has an
idea about how to make this work under SciTe. It’s my guess that
SciTe doesn’t want to put a cursor in its output pane and accept
keystroke that it could pipe into the stdin stream. Is that the end
of the story? Is there a more appropriate NG to post this question?
I should have mentioned that I’m running under Win2000ProSP3.
I made some progress on getting gets to work under SciTe:
print "Enter text: " + “\n”
Newline added to make SciTe ver. somewhat match Command line version
f = File.new(“con:”)
while f.gets
f.close # Added to try to get the loop to work
chomp!
puts ‘Got "’ + $_ + '"'
print 'Enter more: '
f = File.new(“con:”) # Added to try to get the loop to work
end
Of course, this is pretty crude:
The output appears in an SciTe pane
The input is entered in a Command window (with Ctrl-Z on the next line)
The program terminates instead of executing the next File.new.
print “Enter text: "
while gets
chomp!
puts ‘Got "’ + $_ + '”’
print 'Enter more: ’
end
But running it in the SciTe 1.41 environment with Ruby 1.6.8, I get:
Enter text: IO_Test1.rb:2:in `gets’: Bad file descriptor
(Errno::EBADF)
I’ve asked about this before on this NG, but wonder if anybody has an
idea about how to make this work under SciTe. It’s my guess that
SciTe doesn’t want to put a cursor in its output pane and accept
keystroke that it could pipe into the stdin stream. Is that the end
of the story? Is there a more appropriate NG to post this question?
TIA,
Richard
I get the same on 1.41 (Win98se) with your script.
The STDIN Ruby sees is an IO object but with STDIN.fileno == -1
(should be 0). My guess is that this was fixed long ago in
a later SciTE release.
I know not why the 1.41 relic is distributed.
There’s a SciTE 1.52 ‘one-click’ installer for Windows.
(Includes a shell extension which adds ‘Edit with SciTE’ to the
right-click context menu for all files.)
I get the same on 1.41 (Win98se) with your script.
Thanks for confirming that I wasn’t doing something really stupid.
The STDIN Ruby sees is an IO object but with STDIN.fileno == -1
(should be 0).
Thanks for diagnosis. I didn’t think the solution would be as simple
as an incorrect file hand for the stdin stream.
There’s a SciTE 1.52 ‘one-click’ installer for Windows.
(Includes a shell extension which adds ‘Edit with SciTE’ to the
right-click context menu for all files.)
Thanks for the URL. I installed 1.52 and under Win2000SP3 and saw the
new entry in the context menu. That’s more convient than selecting
“Open with …” and then selecting SciTE, as was the case with the
version I was using previously.
However, 1.52 works worse than my old version did with respect to
gets. Output from the first print stmt is not displayed and the gets
statement results in a new Command window that ignores all keystrokes,
including Alt-F4 and Ctrl-C. And when the Command window is closed,
the script terminates with:
Exit code: -1073741510
Free of charge.
That’s really neat. This particular Newsgroup is great. Without it,
I’d have stayed with Perl rather than tackle a new language, i.e.
Ruby.
In this version, your script runs as you would expect.
That’s what I had hoped, but that was not the case as you saw above.
I also tried it on SciTE ver. 1.52-wdb1, which produced no perceptible
difference from 1.52.