Using 'gets' with SciTe under Win2000

Hi All,

The following runs fine in a Command window:

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 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:

  1. The output appears in an SciTe pane
  2. The input is entered in a Command window (with Ctrl-Z on the next line)
  3. The program terminates instead of executing the next File.new.

Any comments?

Regards,
Richard

“Richard” RLMuller@comcast.net wrote in message news:32c026de.0306081458.2d1b5975@posting.google.com

Hi All,

The following runs fine in a Command window:

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.)

SciTE - Scintilla Text Editor

Just over 1MB (4min d/l @ 56K) - fits on a floppy.

Free of charge.
(Thanks - Neil Hodgson, Andre Burgaud, Bruce Dodson et al. :)))

It makes an excellent replacement for Notepad.

In this version, your script runs as you would expect.

daz

Hi Daz,

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.)

SciTE - Scintilla Text Editor

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.

Again, thanks for the help.

Regards,
Richard

In the Tools menu - Stop Executing (greyed out when not executing).

Next to that is the accelerator key combo Ctrl+Break.

This should transport you from the land of woe to a paradise island
near Honolulu that is SciTE 1.52 :wink: (Other editors are available).

daz

···

“Richard” RLMuller@comcast.net wrote:

… and the gets statement results in a new Command window that
ignores all keystrokes, including Alt-F4 and Ctrl-C.