Using 'gets' with SciTe under Win2000 
Author Message
 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



Fri, 25 Nov 2005 06:58:15 GMT  
 Using 'gets' with SciTe under Win2000
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



Fri, 25 Nov 2005 12:37:37 GMT  
 Using 'gets' with SciTe under Win2000

Quote:

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

  http://gisdeveloper.tripod.com/scite.html


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



Sat, 26 Nov 2005 04:05:05 GMT  
 Using 'gets' with SciTe under Win2000
Hi Daz,

Quote:
> I get the same on 1.41 (Win98se) with your script.

Thanks for confirming that I wasn't doing something really stupid.
Quote:

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

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

>   http://gisdeveloper.tripod.com/scite.html

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

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

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



Sat, 26 Nov 2005 12:17:30 GMT  
 Using 'gets' with SciTe under Win2000

Quote:

> Output from the first print stmt is not displayed ...

$stdout.sync=true

at the top will keep the buffers flushed.

Quote:
> Again, thanks for the help.

(Ack:)

Quote:
> Regards,
> Richard

daz


Sat, 26 Nov 2005 14:11:04 GMT  
 Using 'gets' with SciTe under Win2000

Quote:

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

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 ;)   (Other editors are available).

daz



Sat, 26 Nov 2005 16:25:44 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. using 'system' under win2000/nt/9x

2. Win2000 has 63,000 'defects'

3. Getting a lock using Int 21h under Windows '95

4. Variable number of 'gets'

5. C5.5 ABC getting 'My Computer'

6. getting rid of '{}'

7. Getting Ascii string from hex 'string'

8. Getting rid of 'warning' in Clisp

9. problem with 'gets' command

10. 'gets' - pipe problem

11. Getting rid of Mcafee 'purchase' reminder

12. The Smalltalk Store: Why we've been slow, and why we're getting better

 

 
Powered by phpBB® Forum Software