Forum: Ruby Really basic Ruby question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
67c060f4e550dbbf9f861c3edfe5d027?d=identicon&s=25 paul.denlinger@gmail.com (Guest)
on 2006-03-25 20:24
(Received via mailing list)
I'm learning Ruby from the Learn to Program tutorial by Chris Pine.

On http://pine.fm/LearnToProgram/?Chapter=01, he mentions saving a
calc.rb file after typing in "puts 1 + 2" in my text editor , then
going to the command line and typing "ruby calc.rb", and getting the
results "3" returned.

I am not getting this result; instead I'm getting a message that the
file or directory can't be found. I'm using the built-in Scintilla text
editor which comes with Ruby.

How do I get the command line to see the saved file?

Thanks in advance for your assistance.
Be13d49ea40add75e564bef96b323caf?d=identicon&s=25 13 (Guest)
on 2006-03-25 20:39
(Received via mailing list)
Hi,

Looks like you are using Scite editor. If so, you can press F5 and see
program output directly in Scite.

--
Martins
A7d0c9261d7bdfec78bb2cadbe6de701?d=identicon&s=25 David Newberger (Guest)
on 2006-03-25 20:40
(Received via mailing list)
What directory is the saved file in would be my first question.

ruby /path/to/calc.rb

would be the first thing that comes to mind.

David Newberger
651.271.9045
me@davidnewberger.com
http://www.davidnewberger.com
05be5d6610e2c3f1780aa0e39e902e93?d=identicon&s=25 Farrel Lifson (Guest)
on 2006-03-25 20:41
(Received via mailing list)
Have you saved the program to file called 'calc.rb' and run 'ruby
calc.rb' from the directory it's in?
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-03-25 20:49
(Received via mailing list)
paul.denlinger@gmail.com wrote:
>
> How do I get the command line to see the saved file?

You may be opening the command prompt in some default home directory,
which is not the same place where you saved the Ruby file.

When you save the file in Scintilla, make sure you save it to c:\calc.rb

Then, when you get a command prompt, go to the C: drive, then change to
the root drive:

   c:\>  cd \

Then try running ruby calc.rb.


If that works, all is good.

You will probably be able to run it by just typing the file name and
hitting Enter, too, if the Ruby installation set up the filetype
execution association for you.

Now, I don't generally advocate saving your files to the root of the C:
drive, so decide where you want to place the files, and then just figure
out how to navigate there once you have a command prompt.


--
James Britt

"In Ruby, no one cares who your parents were, all they care
  about is if you know  what you are talking about."
   - Logan Capaldo
67c060f4e550dbbf9f861c3edfe5d027?d=identicon&s=25 paul.denlinger@gmail.com (Guest)
on 2006-03-25 21:04
(Received via mailing list)
Thank you. It works!
Ffcb418e17cac2873d611c2b8d8d891c?d=identicon&s=25 Benjohn Barnes (Guest)
on 2006-03-26 11:05
(Received via mailing list)
On 25 Mar 2006, at 20:03, paul.denlinger@gmail.com wrote:

> Thank you. It works!

If you are learning, you might want to try the interactive ruby
interpreter: irb. That will save you writing things, saving them, and
trying them. For simple tests it is very quick. To use it, go to your
command line and type:

	irb

And then you're be able to type "puts 1 + 2" and see the result
directly.

Have fun anyway!

Cheers,
	Benjohn
67c060f4e550dbbf9f861c3edfe5d027?d=identicon&s=25 paul.denlinger@gmail.com (Guest)
on 2006-03-26 17:28
(Received via mailing list)
Thank you very much for the suggestion.
This topic is locked and can not be replied to.