[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

gets.chomp....... not function

Vister Gade

4/14/2008 3:13:00 AM

heloo.... i m a beginner of ruby...

so i have a problem about gets function or gets.chomp.....

when i run at SciTE.... it will not do anything... just a command
blank....
if i run it from file to ruby interpreter... the question will appear...
but when i insert input and enter... it will disappear....


what are the problem is had... and what are the solution.....

please help.....

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

6 Answers

Daniel Finnie

4/14/2008 3:28:00 AM

0

Hi,

Can you post your code?

Generally, programs requiring user interaction do not work well in
programs like SCiTE and should be run from the command line.

Here is an example of using gets:
puts "What is your favorite color?"
color = gets
if gets == "red"
puts "that's mine too!"
else
puts "bad choice..."
end

Dan

On Sun, Apr 13, 2008 at 11:13 PM, Vister Gade <gade_vd@yahoo.com.sg> wrote:
> heloo.... i m a beginner of ruby...
>
> so i have a problem about gets function or gets.chomp.....
>
> when i run at SciTE.... it will not do anything... just a command
> blank....
> if i run it from file to ruby interpreter... the question will appear...
> but when i insert input and enter... it will disappear....
>
>
> what are the problem is had... and what are the solution.....
>
> please help.....
>
> thanks...
> --
> Posted via http://www.ruby-....
>
>

Vister Gade

4/14/2008 4:05:00 AM

0

puts ' What is your full name?'
name = gets.chomp
puts ' Did you know there are ' + name.length.to_s + ' characters'
puts ' in your name, ' + name + ' ?'
--
Posted via http://www.ruby-....

Kyle Hunter

4/14/2008 4:26:00 AM

0

Vister Gade wrote:
> heloo.... i m a beginner of ruby...
>
> so i have a problem about gets function or gets.chomp.....
>
> when i run at SciTE.... it will not do anything... just a command
> blank....
> if i run it from file to ruby interpreter... the question will appear...
> but when i insert input and enter... it will disappear....
>
>
> what are the problem is had... and what are the solution.....
>
> please help.....
>
> thanks...

The Windows command prompt closes after the program is done running
unless the program was run by an already existing command prompt IIRC.
My advice would be to opening a command prompt, and running it from an
already opened command prompt. This should allow you to see the output
of your program.


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

Vister Gade

4/14/2008 5:15:00 AM

0

Kyle Hunter wrote:
> Vister Gade wrote:
>> heloo.... i m a beginner of ruby...
>>
>> so i have a problem about gets function or gets.chomp.....
>>
>> when i run at SciTE.... it will not do anything... just a command
>> blank....
>> if i run it from file to ruby interpreter... the question will appear...
>> but when i insert input and enter... it will disappear....
>>
>>
>> what are the problem is had... and what are the solution.....
>>
>> please help.....
>>
>> thanks...
>
> The Windows command prompt closes after the program is done running
> unless the program was run by an already existing command prompt IIRC.
> My advice would be to opening a command prompt, and running it from an
> already opened command prompt. This should allow you to see the output
> of your program.



Thanks... can u teach me how to run in step by step.... sorry but i
really needing u help....

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

Phillip Gawlowski

4/14/2008 5:22:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vister Gade wrote:

|> The Windows command prompt closes after the program is done running
|> unless the program was run by an already existing command prompt IIRC.
|> My advice would be to opening a command prompt, and running it from an
|> already opened command prompt. This should allow you to see the output
|> of your program.
|
|
|
| Thanks... can u teach me how to run in step by step.... sorry but i
| really needing u help....

Start -> Run... -> cmd<enter> -> help<enter>

Navigate to the directory you saved the Ruby script, and type "ruby
name_of_your_script.rb".

This assumes that Ruby is in your path. Otherwise, you'll have to type
in the path to ruby.exe, too (For example: "c:\ruby\bin\ruby.exe
your_scrupt.rb").

More help can be found here: http://www.... /


- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

~ - You know you've been hacking too long when...
...you've been low-level debugging ethernets for a week and you see two
people at a table trying to pick up the same jar of butter and you
directly wonder if they are using the correct CSMA/CD algorithm to avoid
a re-collision.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail....

iEYEARECAAYFAkgC6fsACgkQbtAgaoJTgL8K2wCgp8bne4hva7aPHeF88QCSmtXS
HsQAn1AaZVHSKHb1oKwYaJ+r8BaWagXx
=Uu7T
-----END PGP SIGNATURE-----

Marc Heiler

4/14/2008 11:25:00 AM

0

> Thanks... can u teach me how to run in step by step.... sorry but i
> really needing u help....

For testing purposes you should use irb (irb.bat or whatever the name on
windows was), this way you are independent of a GUI (and bugs or
problems inside that GUI) too.
--
Posted via http://www.ruby-....