David Vallner
11/6/2006 10:40:00 PM
John Tar wrote:
> Hi
>
> I am a newbie. I am trying to run some small ruby programs to learn a
> bit about ruby.
>
> everytime i run the following program in windows it auto closes when it
> is done, so there is no time to see the final result
>
> is there any way to allow it to just freeze and not autoclose...the way
> i was doing it,is by putting a gets at the end....but i am sure there is
> a better way
>
> thanks
>
> john
>
> code:
>
>
> puts 'what is you first name?'
> name = gets.chomp
> a=name.length.to_i
> puts a
>
> puts 'what is you midlle name?'
> mname=gets.chomp
> b=mname.length.to_i
> puts b
>
> puts 'what is you last midlle name?'
> lname=gets.chomp
> c=lname.length.to_i
> puts c
>
> d=a+b+c
>
> puts 'there are ' + d.to_s + ' characters in your name:' +
> mname.swapcase
>
>
>
>
A method using less busywork to run the script itself would be adding:
puts "Press ENTER to close."
gets
at the end of the script.
This should only be done in interactive programs, and is a workaround,
but it's Good Enough.
David Vallner