Topic: Question about running Ruby code

Hi--

I'm trying to run this Ruby program (Celsius to Fahrenheit converter) in SciTE:

print "Hello, please enter a Celsius value: "
c=gets
f=(c.to_i*9/5)+32
print "The Fahrenheit equivalent is "
print f
puts "."

When I run the code, a command/terminal window pops up and I try to enter a number value. The thing is, the command/terminal window, for some reason, does not take input and let me enter a value.

I have an exit code of -1073741510 when I exit the code.

Can someone tell me what I'm doing wrong?

Thanks in advance,

Paul

Re: Question about running Ruby code

theres nothing wrong with your program (ruby for rails is it?). might be down to the computer it self. how are you running the program? are you just typeing "ruby c2f.rb" in terminal?

Last edited by BasicMind (2007-03-17 17:43:38)

--

Re: Question about running Ruby code

I'm running it in the Windows command line.

After invoking it, I then enter "irb" to get into the Ruby interactive shell. Then I enter "ruby c2f.rb"

Do I need to enter a path?

Thanks in advance.

Re: Question about running Ruby code

You don't run ruby from within irb.  From your dos/unix prompt, just run 'ruby c2f.rb', and it should run.  I just pasted your code into a file on my system, and it ran fine.

BrewControl.com - Brewery and Brewpub management powered by RoR

Re: Question about running Ruby code

and yes you will need a path. best to navigate to the folder with all your ruby stuff through the dos prompt.

--

Re: Question about running Ruby code

OK, thank you.