On 2013-06-23, at 6:04 PM, "Michael P F." <lists / ruby-forum.com> wrote:

> It runs but doesn't pause for a input. Here is the Terminal output
>=20
> michael@michael-desktop:~/Desktop$ ruby<weins.txt
> Enter number: enter a number please.
> Enter number: Bye!
> michael@michael-desktop:~/Desktop$
>=20
>                 Mike

If you saved the program in weins.txt then try

  ruby wiens.txt

When you run you run ruby <weins.txt then the contents of weins.txt are =
used as the standard input stream which ruby consumes and executes, then =
hits the end of file.

On my laptop:

ratdog:tmp mike$ cat try.rb
#!/usr/bin/env ruby

CONST =3D 28977682.9

catch (:done) do
  loop  do
    print "Enter number: "
    throw :done unless response =3D gets

    if num =3D Float(response) rescue nil
      puts CONST / num
    else
      puts "enter a number please."
    end
  end
end

puts "Bye!"

__END__
ratdog:tmp mike$ ruby try.rb
Enter number: 1
28977682.9
Enter number: 2
14488841.45
Enter number: 2.3
12598992.565217393
Enter number: banana
enter a number please.
Enter number: Bye!

(I hit Ctrl-D at the last prompt)

Hope this helps,

Mike

--=20

Mike Stok <mike / stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.