New to Ruby

I'm new to ruby and programming (although I did dabble in BASIC with my
Commodore 64 back in the 80's) I'm running Ruby with Windows XP. I'm
having a problem when I run this simple program:

puts 'Hello, world!'
puts ' '
puts 'Good-bye'

When I run the program, a window appears that says "Hello, world! Good-Buy"
and then the window immediately disappears. How do I get that window to
stay open after it has run the program?

Thanks for your help,

Steve

There might be an option (right click on the .rb file and choose
propeties) for making the window not close on exit.

Otherwise, an easy hack is to do something like
puts "hello world"
puts "we're quitting! press enter now"
gets

···

On 8/29/05, Steve <sdouglas949@yahoo.com> wrote:

I'm new to ruby and programming (although I did dabble in BASIC with my
Commodore 64 back in the 80's) I'm running Ruby with Windows XP. I'm
having a problem when I run this simple program:

puts 'Hello, world!'
puts ' '
puts 'Good-bye'

When I run the program, a window appears that says "Hello, world! Good-Buy"
and then the window immediately disappears. How do I get that window to
stay open after it has run the program?

Steve wrote:

I'm new to ruby and programming (although I did dabble in BASIC with my
Commodore 64 back in the 80's) I'm running Ruby with Windows XP. I'm
having a problem when I run this simple program:

puts 'Hello, world!'
puts ' '
puts 'Good-bye'

When I run the program, a window appears that says "Hello, world! Good-Buy"
and then the window immediately disappears. How do I get that window to
stay open after it has run the program?

Thanks for your help,

Steve

First, start a DOS-box (or command-line interface):

Start / All programs / Accessories / Command Prompt

Assuming your path is set correctly, then type:

ruby myprog.rb

If you used the windows one click installer, you'll probably have the
SciTe editor installed. With SciTe, open your program file and hit
the Tools/Go menu entry to run the script and preserve the output.

Cheers,
- alan

Steve wrote:

I'm new to ruby and programming (although I did dabble in BASIC with my Commodore 64 back in the 80's) I'm running Ruby with Windows XP. I'm having a problem when I run this simple program:

puts 'Hello, world!'
puts ' '
puts 'Good-bye'

When I run the program, a window appears that says "Hello, world! Good-Buy" and then the window immediately disappears. How do I get that window to stay open after it has run the program?

Thanks for your help,

Steve

I prefer to have the command prompt open - putting it in the quicklaunch bar was the first thing I've done after I installed the system :wink: IIRC, the One Click Installer for Windows sets up both PATH and PATHEXT so you can run a file called "hello.rb" by typing only "hello" at the command prompt - just like you'd run a .BAT file.

David Vallner

Steve,

If you're using Scite as your editor (if you're not, it's bundled with
the Windows installer and should be on your Ruby menu somewhere) then
you might want to try this. Change the extension on your source file
from "rb" to "rbw". If you now run your script (F5 is the keyboard
shortcut) then the output is captured in the Scite output window. Plain
"rb" files will still open a quickly-disappearing Command window, which
is, as you've already discovered, tedious.

HTH,

Mike

Or, simply click start, then run and then type "cmd" in the box and
hit enter...

That's the fastest way to a command prompt without adding a shortcut
to your desktop or quicklaunch bar...

j.

···

On 8/29/05, William James <w_a_x_man@yahoo.com> wrote:

Steve wrote:
> I'm new to ruby and programming (although I did dabble in BASIC with my
> Commodore 64 back in the 80's) I'm running Ruby with Windows XP. I'm
> having a problem when I run this simple program:
>
> puts 'Hello, world!'
> puts ' '
> puts 'Good-bye'
>
> When I run the program, a window appears that says "Hello, world! Good-Buy"
> and then the window immediately disappears. How do I get that window to
> stay open after it has run the program?
>
> Thanks for your help,
>
> Steve

First, start a DOS-box (or command-line interface):

Start / All programs / Accessories / Command Prompt

Assuming your path is set correctly, then type:

ruby myprog.rb

--
"So long, and thanks for all the fish"

Jeff Wood

Same as previous but quicker:

WindowsKey + R (Same as Start -- Run)
type "cmd"

Jeff Wood wrote:

Or, simply click start, then run and then type "cmd" in the box and
hit enter...

Anybody knows some windows console software better than cmd?

yeah, but that only works if you have a keyboard *WITH* a windows key ...

j.

···

On 8/29/05, matt.hulse@gmail.com <matt.hulse@gmail.com> wrote:

Same as previous but quicker:

WindowsKey + R (Same as Start -- Run)
type "cmd"

--
"So long, and thanks for all the fish"

Jeff Wood

http://martinus.geekisp.com/rublog.cgi/Projects/fxri/fxri.html

EdUarDo wrote:

···

Jeff Wood wrote:
> Or, simply click start, then run and then type "cmd" in the box and
> hit enter...

Anybody knows some windows console software better than cmd?

I just tried this and it seemed to work, though it is kind of kludgy.
Copy the command prompt shortcut from your menu to the "send to"
folder.

Then take any file and send it to command prompt by right clicking.
It doesn't actually send anything, but it does open the command prompt
window.

Also Alt + S seems to open the start menu, but only if focus is on it. :frowning:

Hope this helps,
Jamal

···

On 8/29/05, Jeff Wood <jeff.darklight@gmail.com> wrote:

yeah, but that only works if you have a keyboard *WITH* a windows key ...

j.

On 8/29/05, matt.hulse@gmail.com <matt.hulse@gmail.com> wrote:
> Same as previous but quicker:
>
> WindowsKey + R (Same as Start -- Run)
> type "cmd"
>
>
>

--
"So long, and thanks for all the fish"

Jeff Wood

Gene Tani wrote:

http://martinus.geekisp.com/rublog.cgi/Projects/fxri/fxri.html

I'll do a try

The normal keystroke for the start menu ( the one hidden by the
windows key ) is Ctrl-Escape.

Simply take a look at the files that were installed with the one-click
installer... Under Ruby->Ruby 1.8.2-15->Samples you will see a
hello.rb ... look at the code at the end ... There's a small bit of
code that does the whole wait for input...

If you need more than that, I would suggest writing a small batch file
to wrap the interpreter and put a pause at the end... same idea but
you then don't have to add anything to your scripts ...

Lots of ways to do it... just gotta choose one.

j.

···

On 8/29/05, Jamal Hansen <jamal.hansen@gmail.com> wrote:

I just tried this and it seemed to work, though it is kind of kludgy.
Copy the command prompt shortcut from your menu to the "send to"
folder.

Then take any file and send it to command prompt by right clicking.
It doesn't actually send anything, but it does open the command prompt
window.

Also Alt + S seems to open the start menu, but only if focus is on it. :frowning:

Hope this helps,
Jamal

On 8/29/05, Jeff Wood <jeff.darklight@gmail.com> wrote:
> yeah, but that only works if you have a keyboard *WITH* a windows key ...
>
> j.
>
> On 8/29/05, matt.hulse@gmail.com <matt.hulse@gmail.com> wrote:
> > Same as previous but quicker:
> >
> > WindowsKey + R (Same as Start -- Run)
> > type "cmd"
> >
> >
> >
>
>
> --
> "So long, and thanks for all the fish"
>
> Jeff Wood
>
>

--
"So long, and thanks for all the fish"

Jeff Wood

Jeff Wood wrote:

The normal keystroke for the start menu ( the one hidden by the
windows key ) is Ctrl-Escape.

Simply take a look at the files that were installed with the one-click
installer... Under Ruby->Ruby 1.8.2-15->Samples you will see a
hello.rb ... look at the code at the end ... There's a small bit of
code that does the whole wait for input...

Just add the following line to the end of your program; it will wait for
[Enter].

gets

If you need more than that, I would suggest writing a small batch file
to wrap the interpreter and put a pause at the end... same idea but
you then don't have to add anything to your scripts ...

I prefer this alternative - you wont need to put "gets" at the end of all
your scripts. Put this ruby.bat in a directory in your path environment
variable before the real Ruby's directory (e.g. C:\Windows):

@echo off
ruby %*
pause

Cheers,
Dave