Forum: Ruby Newbie- cmd wont display .rb file

D1657f8bb427f127b3a28020dfae2c4a?d=identicon&s=25 Inugirl R. (inugirl_r)
on 2014-06-20 02:54
So I just installed ruby and I'm pretty sure I have it set up right, but
when I try and run a .rb file typing "ruby" and then the file name in
the cmd all I get is a blank space. Not even an error. The file is a
simple beginners one that just says puts "hello world". My computer uses
windows 8.
5b972395a92333843018b4add8af0437?d=identicon&s=25 Damián M. González (igorjorobus)
on 2014-06-22 02:55
Did you resolved this? Can you give more information?
D1657f8bb427f127b3a28020dfae2c4a?d=identicon&s=25 Inugirl R. (inugirl_r)
on 2014-06-22 18:32
No I have not resolved it yet. More details like what?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-06-22 19:14
Show us the code inside the file, and the exact command you're executing
to run it. Without this information we cannot help you.

My instinct says that you've wrapped your code up in a method and
forgotten to call the method, but I can't tell that without seeing the
code.
D1657f8bb427f127b3a28020dfae2c4a?d=identicon&s=25 Inugirl R. (inugirl_r)
on 2014-06-22 20:46
No no method. Alls it says is:
puts
"hello"
I was testing to see if it worked. I typed ruby hello.rb into command.
The only output was that it seemed to skip a few lines. Just a blank
black space. No errors.
614aa6cb0cc315b8ef993dea32679642?d=identicon&s=25 John Yd (abettertomorrow80)
on 2014-06-22 22:33
go to Start on lower left hand corner and type "cmd"
then go to the correct folder that contain your hello.rb file
then when u are in the folder that contain your hello.rb, u type "ruby
hello.rb"
614aa6cb0cc315b8ef993dea32679642?d=identicon&s=25 John Yd (abettertomorrow80)
on 2014-06-22 22:34
to go between folders, cd "folder name withouth the double quotes"

type dir to find the current listing in the current directory.
D1657f8bb427f127b3a28020dfae2c4a?d=identicon&s=25 Inugirl R. (inugirl_r)
on 2014-06-22 23:28
I was in the correct folder. It didn't give me an error saying the file
didn't exist. Though I didn't type the command in double quotes.
54404bcac0f45bf1c8e8b827cd9bb709?d=identicon&s=25 7stud -- (7stud)
on 2014-06-23 00:25
>No no method. Alls it says is:

>> puts
>>"hello"

The first line tells ruby to output the argument you supplied to puts(),
followed by a carriage return(known as a 'newline' in computer
programming).   Because you didn't supply an argument to the puts()
method, ruby just outputs the newline, which your terminal displays as
a blank line.

The second line tells ruby to create a String(that's what double quotes
do), and because you didn't assign the String "hello" to a variable, it
is discarded.

Then your program ends.

Any questions?
D1657f8bb427f127b3a28020dfae2c4a?d=identicon&s=25 Inugirl R. (inugirl_r)
on 2014-06-23 01:09
Well that's all the tutorial told me to put. So then how would I type it
to get it to display "hello" ? And thank you for the help.
54404bcac0f45bf1c8e8b827cd9bb709?d=identicon&s=25 7stud -- (7stud)
on 2014-06-23 23:05
> Well that's all the tutorial told me to put.

Do you have a link to the tutorial?

> So then how would I type it
> to get it to display "hello"

Reread my explanation of your code:

==
The first line tells ruby to output the argument you supplied to puts(),
followed by a carriage return(known as a 'newline' in computer
programming).   Because you didn't supply an argument to the puts()
method...
==

Does that give you any ideas?
D1657f8bb427f127b3a28020dfae2c4a?d=identicon&s=25 Inugirl R. (inugirl_r)
on 2014-06-24 02:55
Ahh...i get it. Everything shows up fine now. Thank you for your
assistance in this matter.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.