"Hal Fulton" <hal9000 / hypermetrics.com> wrote:
> daz wrote:
> > "{ vidya }" <vidu108 / yahoo.com> wrote:
> >
> >
> >>hi,
> >>
> >>I am not sure if this is the right address to send my question ..so.. !
> >>
> >>Is Ruby language a good choice for a terminal emulation software with
> >>an IBM mainframe ?
> >>i have to convert and port a terminal emulator currently in "C" lang
> >>for communicating with the IBM mainframe.
> >>It is in the MSWindows OS platform  and i want to port it to the
> >>Gnu/Linux OS platform but will it work if the client has another OS/s?
> >>Would Ruby be a better option to C++ ?
> >>thanks for your time,
> >>
> >
> >
> > I'd guess that your "C" program is making use of the getch() function
> > (directy or indirectly).
> > Because this isn't available with all compilers, Ruby uses getchar()
> > which, under Win32, gets too much "help" from DOS (e.g. DOS echoes
> > the characters as you type but doesn't return the input until getchar()
> > sees end-of-line).  I don't know *nix but I'm fairly sure this problem
> > isn't there.
> >
> > So, a compiled-for-Win32 Ruby interpreter has this anomaly built-in.
>
> Hmm, I think if you "grab" a character you don't get an echo.
>

His emulator in "C" will be doing that but if I run this Ruby:

   $stdout.sync=true
   c = STDIN.getc
   p 'END'

and type   z

 I see  z  alone on the console.

 When I press return, I see  z  on line 1 and "END" on line 2.
I think you'll agree, I "grabbed" the  z, didn't want to see it
but did, didn't want to press return but had to or else I never
would have seen 'END'.


> > You can work-around by checking the Ruby platform in a script and calling
> > Win32API but then you haven't got one script that will work for all.
>
> This might be acceptable for him. Is Win32API a part of the
> standard Ruby distribution on Windows?

Yes.

> If so, the difference should be imperceptible to the user.

This is based on one of the Win32API examples:

   require 'Win32API'
   getch = Win32API.new("crtdll", "_getch", [], 'L')

   c = getch.Call
   p 'END'
   p c.chr

Displays "END" as soon as I press  z  (which isn't echoed),
then prints the result I requested ("z") and terminates.

So it's possible.


>
> Hal
>

daz

(Apologies to treasurers and students of the English language
for the hyphen in "... has this anomaly built-in".)