Getting information from keyboard

Hi
I am reading a book about ruby, it learn me that I write my program in
SciTE and then use F5 in keyboard to run my program.
Now , today I write this very very simple program :

a = gets.chomp!

when I write this code in Interactive Ruby enviroment , this code runs
as I want but when I write this code in SciTE and use F5 after some
seconds a black window opens and I can't write anything and I can't use
"gets" instruction in my program.
please help me.
thanks

···

--
Posted via http://www.ruby-forum.com/.

Back when I used SciTE, it didn't have anyway for you to pass data to
standard input. If it's still like this, then you will have to go to the
terminal and run your program with the ruby interpreter `$ ruby yourfile.rb`

···

On Sun, Aug 14, 2011 at 8:02 AM, amir e. <aef1370@gmail.com> wrote:

Hi
I am reading a book about ruby, it learn me that I write my program in
SciTE and then use F5 in keyboard to run my program.
Now , today I write this very very simple program :

a = gets.chomp!

when I write this code in Interactive Ruby enviroment , this code runs
as I want but when I write this code in SciTE and use F5 after some
seconds a black window opens and I can't write anything and I can't use
"gets" instruction in my program.
please help me.
thanks

--
Posted via http://www.ruby-forum.com/\.

hi,

  i use SciTe regularly, and like it a lot, but unfortunately #gets will
not work with it... you'll have to run the program from the terminal as
mentioned above.

- j

···

--
Posted via http://www.ruby-forum.com/.

please explain me more obvious.
thanks

···

--
Posted via http://www.ruby-forum.com/.

SciTE is great for its highlighting, and the fact that you can run
(most) scripts by pressing F5 - unfortunately, the "gets" method won't
work with SciTe... you'll have to run the program from a terminal.

  under ubuntu / linux it should be in Main Menu -> Accessories ->
Terminal, under windows i think it's Start -> Run, but i'm not sure
(google it)

  let's say that your program is named "my_program.rb" - in the terminal
type:

ruby my_program.rb

  this should run the program, and let you use the "gets" method as you
expect.

- j

···

--
Posted via http://www.ruby-forum.com/.

Hi
I have a problem with ruby documentation , I mean that I don't
understand ruby documentation for example in the image that is attached
to this file I don't understand meaning of highlighted sections.
Please someone explain completely .
thanks

Attachments:
http://www.ruby-forum.com/attachment/6532/Capture.PNG

···

--
Posted via http://www.ruby-forum.com/.

Bartosz Dziewoński , I am very thankful from you. but I have another
question I don't understand exactly what is the [,opt] and how can I use
that ?
thanks

···

--
Posted via http://www.ruby-forum.com/.

jake kaiden wrote in post #1016606:

hi,

  i use SciTe regularly, and like it a lot, but unfortunately #gets will
not work with it... you'll have to run the program from the terminal as
mentioned above.

- j

It is hard to find, but possible to enter data from stdin
with SciTE.

Just press F8 (so the output-pane is visible) and enter the data there.

Additionally, the OP should use chomp instead of chomp! as the latter
may return nil.

http://ruby-doc.org/core/classes/String.src/M001195.html

···

--
Posted via http://www.ruby-forum.com/\.

Meaning of highlighted sections in attachment:

IO.open(fd, mode_string="r" [, opt] ) → io
IO.open(fd, mode_string="r" [, opt] ) {|io| block } → obj

* the dark-grey header shows variants of this method's signature, that
is, how you can use it.
** first comes the class name and the method name
** then, in parentheses, description of arguments. "fd" argument is
mandatory, "mode_string" is optional with default value being "r" (why
"r" is explained below), "opt" is also optional with no default value.
** later, only in the second variant, comes the information how you
can call this function with a block.
** finally, after the arrow, what is the value returned by this
variant. First variant returns an IO object, second returns the value
of the block (this is, once again, explained in the text below).
-- Matma Rex

···

2011/8/14 amir e. <aef1370@gmail.com>:

Hi
I have a problem with ruby documentation , I mean that I don't
understand ruby documentation for example in the image that is attached
to this file I don't understand meaning of highlighted sections.
Please someone explain completely .
thanks

Attachments:
http://www.ruby-forum.com/attachment/6532/Capture.PNG

--
Posted via http://www.ruby-forum.com/\.

The square brackets are there simply to indicate this is an optional argument.

You can sometimes even come across methods that have nested brackets -
e.g. something( arg1 [, arg2 [, arg3 ]] ) - this simply means that all
arguments except the first are optional. This is a quite widely used
convention, also present in, for example, PHP documentation.

-- Matma Rex

···

2011/8/14 amir e. <aef1370@gmail.com>:

Bartosz Dziewoński , I am very thankful from you. but I have another
question I don't understand exactly what is the [,opt] and how can I use
that ?
thanks

--
Posted via http://www.ruby-forum.com/\.

Stefan Mahlitz wrote in post #1016615:

It is hard to find, but possible to enter data from stdin
with SciTE.

Just press F8 (so the output-pane is visible) and enter the data there.

  i'd be very interested to know how this has worked for you... when i
use SciTe (with the output-pane visible,) the following code:

  name = gets.chomp
  puts "hi #{name}"

  ...gives me this error:

=> private method `chomp' called for nil:NilClass (NoMethodError)

  while if i run the program from a terminal, it works as expected...

  - j

···

--
Posted via http://www.ruby-forum.com/\.