[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

interact with Ruby via command prompt window dynamically

Li Chen

10/15/2007 1:27:00 PM

Hi all,

I use SciTE for Ruby scripting. I wonder if it is possible to
dynamically interact with my script via command prompt from within
SciTE. For example I want to get user input and then print it to the
command prompt window.

//script
input=STDIN.gets
puts input

It works if I execute the script from a prompt window but doesn't work
via SciTE. I wonder what is the Ruby way to interact with the user from
the command prompt window.

Thanks,

Li
--
Posted via http://www.ruby-....

1 Answer

Stefan Mahlitz

10/16/2007 5:50:00 PM

0

Li Chen schrieb:
> Hi all,
>
> I use SciTE for Ruby scripting. I wonder if it is possible to
> dynamically interact with my script via command prompt from within
> SciTE. For example I want to get user input and then print it to the
> command prompt window.
>
> //script
> input=STDIN.gets
> puts input
>
> It works if I execute the script from a prompt window but doesn't work
> via SciTE. I wonder what is the Ruby way to interact with the user from
> the command prompt window.

It does work for me.

> print("Enter some text: ")
> $stdout.flush
> input = gets
> puts("You entered <#{input}>")
>
> Running in SciTE it open a cmd prompt (where the ruby interpreter is
> called).
>
> Output goes to SciTE-output pane - so you can ignore the cmd-window.
> Just switch back to SciTE to enter the data and see the output.

I did use the output-pane for entering the data.

Stefan