Running ruby

Hi Everyone…I am a very new ruby user. I have downloaded ruby to my
computer (windows98). I have a ruby icon on my desktop with the name
hello. In the notepad part of the icon (hello.rb) are the following
words:

#generate some simple output (comment)
puts “Hello World”

When I click on the icon, a small screen appears with the name ruby.
The screen in visible for a few seconds. Then it disappears. The
screen is black and the words on it are white. I can’t read the words
because the screen disappears too quickly.

How can I make the screen stay visible until I choose to click it off?
How can I change the screen so that the words are in black letters on
a white background?

Thanks for your help. Yahdoco

yahdoco wrote:

How can I make the screen stay visible until I choose to click it off?
How can I change the screen so that the words are in black letters on
a white background?

Hiya!

What about adding a gets at the end?

On Tuesday 04 September 2007 11:20:05 am yahdoco wrote:

screen is black and the words on it are white. I can’t read the words
because the screen disappears too quickly.

How can I make the screen stay visible until I choose to click it off?
How can I change the screen so that the words are in black letters on
a white background?

Thanks for your help. Yahdoco

Go to the start menu > Run, and type “cmd” (sans quotation marks). This
should open a command prompt you can use to run it (“ruby hello.rb”).

Hope it helps,

I sill have the same two problems:
(1)The hello world screen disappears quickly.
(2)The letters are white on a black background.
I tried using MyComputer>ControlPanel>Display and the
DialogBox(Appearance) but nothing changed.
Any other ideas out there?
Thanks. Yahdoco

yahdoco wrote:

I sill have the same two problems:
(1)The hello world screen disappears quickly.
What have you tried? Can you post some code?

(2)The letters are white on a black background.

I tried using MyComputer>ControlPanel>Display and the
DialogBox(Appearance) but nothing changed.
Any other ideas out there?
Right click on the title bar of the console window, and select
Properties. Set the colours up on the Colors tab. I don’t know if it’s
possible to control this from Ruby - I’d expect it would be, but I’ve
never needed to…

On Sep 4, 2:24 pm, Lloyd L. [email protected] wrote:

yahdoco wrote:

How can I make the screen stay visible until I choose to click it off?
How can I change the screen so that the words are in black letters on
a white background?


Hiya!
What about adding a gets at the end?


I changed the file hello.rb to the following:
#generate some simple output (comment)
puts “Hello World”
gets

-----Original Message-----
From: yahdoco [mailto:[email protected]]
Sent: Tuesday, September 04, 2007 10:15 PM
To: ruby-talk ML
Subject: Re: running ruby

I sill have the same two problems:
(1)The hello world screen disappears quickly.

This is your Command Prompt. You can open it via Run -> “cmd” in the
box, or
via your Programs in Accessories (IIRC, it is there. It should have an
icon
reading MS-DOS). Then, you’ll have a command prompt in black with
grayish
text, eagerly awaiting to do your bidding. Tell it to go to your
desktop, by
typing in “cd c:\documents and settings<put your user name
here>\Desktop”.
That should get you where you have placed your hello.rb file.

Once you are at the place you saved your hello.rb, just type “ruby
hello.rb”, and you’ll see the output of your command prompt.

If you cannot find your hello.rb, just type “irb” at the command prompt,
and
you enter the interactive Ruby shell. You can experiment with Ruby
there,
too.

Please note: I’m not sure about the place of your Desktop, since it has
been
ages since I’ve worked with Windows 98.

On Tuesday 04 September 2007 01:15:04 pm yahdoco wrote:

I sill have the same two problems:
(1)The hello world screen disappears quickly.
(2)The letters are white on a black background.
I tried using MyComputer>ControlPanel>Display and the
DialogBox(Appearance) but nothing changed.
Any other ideas out there?
Thanks. Yahdoco

Don’t just type “hello.rb” in the run box. Type “cmd”, and you get a
command
prompt that doesn’t go away quickly, as I told you in the first email.

On 9/4/07, Konrad M. [email protected] wrote:

prompt that doesn’t go away quickly, as I told you in the first email.
Actually, in W98, I believe the command is “command” not “cmd”.

To the OP:

Most rubyists run their programs from the command line. But if you
truly want to double click on an icon to run a program, you’ll need
two files.

If your hello.rb file is in c:\ruby, you will need to create a file on
your desktop (or wherever) containing this text: “ruby
c:\ruby\hello.rb %1”, and then rename it to have a .cmd extension (not
tested, by the way, since I don’t have W98).

hth,

Todd

If your running Windows 98 I think you have to type command.com into the
run
dialog box, but you should also have MS-DOS located under your start
menu
somewhere. Just open up a Dos prompt and then go to the directory where
the
program is held and type

C:>ruby hello.rb

~Jeremy

Don’t just type “hello.rb” in the run box. Type “cmd”, and you get a command
prompt that doesn’t go away quickly, as I told you in the first email.


I click on start>run and I get a dialog box with the word OPEN:
I enter the word cmd and I get an error Dialog Box with the words:
Cannot find tye file ‘cmd’ (or one of it’s components). Make sure the
path and filename are correct and that all required libraries are
available.
The hello.rb program does not run.
It only runs when I enter “hello.rb”, but the response (an active
window with the name ruby) come up and then quickly disappears.
Any other ideas? Thanks. Yahdoco

On Tuesday 04 September 2007 02:00:09 pm yahdoco wrote:

Don’t just type “hello.rb” in the run box. Type “cmd”, and you get a
command
Any other ideas? Thanks. Yahdoco
As Todd pointed out, the program to run in W98 is “command”, not “cmd”

you should try that. You should also probably get a newer operating
system,
sheesh.

Hi,

At Wed, 5 Sep 2007 05:18:28 +0900,
Alex Y. wrote in [ruby-talk:267595]:

Right click on the title bar of the console window, and select
Properties. Set the colours up on the Colors tab. I don’t know if it’s
possible to control this from Ruby - I’d expect it would be, but I’ve
never needed to…

I guess you can do it by setting the ColorTable## under the
registory key, \HKEY_CURRENT_USER\Console. I don’t know if
there are other ways.

Nobuyoshi N. wrote:

registory key, \HKEY_CURRENT_USER\Console. I don’t know if
there are other ways.

I was thinking more along the lines of control codes. You can run
“color 70” at the command prompt, and that’ll invert the colours
(documented here:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true)
but I can’t think how to do that from within a script running under that
shell.

Don’t just type “hello.rb” in the run box. Type “cmd”, and you get a command
prompt that doesn’t go away quickly, as I told you in the first email.

Actually, in W98, I believe the command is “command” not “cmd”.


Hi Todd…You are correct. I took the following path:

START>
RUN>
Enter “command” and click on OK.

I got a window on my desktop>
Title=MS-DOS PROMPT
Content=C:\WINDOWS\Desktop>

At this point I tried words like:
run hello.rb
hello
hello.rb

but the message that came back was:

Bad Command

followed by C:\WINDOWS\Desktop>

What statement should I enter after Desktop>?

Thanks for your help. I seem to be learning new things and making a
lttle progress. Yahdoco

On 9/5/07, yahdoco [email protected] wrote:

Bad Command

followed by C:\WINDOWS\Desktop>

What statement should I enter after Desktop>?

Thanks for your help. I seem to be learning new things and making a
lttle progress. Yahdoco

The run command is “ruby” :slight_smile:

So, you would type:

ruby hello.rb

Just remember that when you are in the command prompt, you have to be
in the same directory as where your hello.rb file is. In this case,
you should be, because you are in c:\windows\Desktop which is the
directory (also known as folder) that holds the files that you see on
your real desktop.

Todd

Hi Everyone…Something interesting happened yesterday when I turned
off my computer at the end of the day. After the desktop screen
disappeared, all of the ruby windows that appeared for a short time
and then disappeared were on the next screen. Apparently, by clicking
on the hello icon, I am sending the answer to the MSDOS WINDOOW(?)
behind the desktop.

(1)How do I make the response appear as a ruby window on top of my
desktop screen?
(2)How do I change this response so that it consists of black text on
a white screen?

Thanks for your help. I am going to review all of the messages I have
received so far an see what I can learn from them. Yahdoco

Hi,

At Wed, 5 Sep 2007 16:19:31 +0900,
Alex Y. wrote in [ruby-talk:267699]:

I was thinking more along the lines of control codes. You can run
“color 70” at the command prompt, and that’ll invert the colours
(documented here:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true)
but I can’t think how to do that from within a script running under that
shell.

system(“color 70”)

Hi,

At Thu, 6 Sep 2007 16:53:26 +0900,
Alex Y. wrote in [ruby-talk:267858]:

system(“color 70”)

And there’s me thinking that wouldn’t work because it would execute in a
subshell… I guess I should try these things before writing them off :slight_smile:

I’d tried it on Windows XP Home. Since a console isn’t a
per-process resource, it works regardless which process did it.

Hi Everyone…With the help of trial and error, I have made some
progress. I modified my hello.rb file by adding some ruby code that I
found on the web. The added code contained an analysis of a stock
using a yahoo website. (Actually, my interest in ruby is to do some of
my own stock market analysis). In the code was a request to enter a
stock symbol. This request kept the ruby window (with the “Hello
World” statement) on my desktop as it waited for me to enter a stock
symbol. Once I entered the symbol, a long calculation was made and
then the ruby window disappeared. Thus, one way to keep the window in
view is to add a request for input. I suppose a pause statement might
also work.

(1)Is there another way to keep the window in
view until I enter an exit command?

(2) I still have the problem that the window consists of white
characters on a black background. Is there a ruby command to change
the window or create another window with features that I can control?

Thanks for your help. Yahdoco

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs