I have been reading the book (Pragmatic Programmers) and I’m having
trouble. When I make a folder and right-click to create a “New” Ruby
Program, the option for Ruby is not there. So I used Text Doc and saved
as .rb (found on a website to use this). It saves as a Ruby P., but
I cannot open or edit the program. It starts to open and then closes
before the window even open properly. Am I doing something wrong?
Also, when I tried to Command Promt to run the program, it kept telling
me it was not valid. Please help.
I am running Windows 7 and trying to use the latest Ruby download from
the site.
Thanks
right click and choose “edit with” to edit the file. it might say “open
with” (been a while since i used windows).
the reason double-clicking doesnt work is windows is trying to run the
program (not edit it). hope that helps.
Sent from my finger. Forgve typoos
Hello Kerri
This is the “Learn to Program” book by Chris P.? I haven’t read it,
but heard good things.
Google pointed to this web site:
http://pine.fm/LearnToProgram
The info on the site is a bit dated (Ruby 1.8.x is ancient), in
particular the latest Ruby installer does not include SciTE
If you have a favourite text editor, use it to edit the .rb files (Ian
has indicated the way).
You can get a SciTE windows installer at
http://opensource.ebswift.com/SciTEInstaller/
As for the command prompt, if the text file is an empty file then
that is probably why it gave the error.
In any case, providing copy of the commands you are using, and the
results you get will make it easier
for others to provide help
Cheers
Chris
kerri l. wrote in post #1061429:
I have been reading the book (Pragmatic Programmers) and I’m having
trouble. When I make a folder and right-click to create a “New” Ruby
Program, the option for Ruby is not there. So I used Text Doc and saved
as .rb (found on a website to use this). It saves as a Ruby P., but
I cannot open or edit the program. It starts to open and then closes
before the window even open properly. Am I doing something wrong?
Also, when I tried to Command Promt to run the program, it kept telling
me it was not valid. Please help.
I am running Windows 7 and trying to use the latest Ruby download from
the site.
Thanks
The book assumes that you have prerequisite knowledge of your OS, in
this case Windows 7, and you obviously do not.
So, here’s a quick primer:
Ruby is an application that interprets a source code text file as a
program it can run. Windows only has “create new” entries that came
default with Windows (like “create new text file”) or that were
installed by other Windows aware applications. Ruby is a cross-platform
application that is not specific to Windows and, therefore, does not
install a “create new Ruby program” entry.
A Ruby source code file is simply a text file that you create and edit
with any text editor, and that is saved with the extension “.rb”
(Optional but recommended). A source code aware text editor, like JEdit
(open-source at http://www.jEdit.org), would be more helpful since it
will support automatic indenting and language-specific syntax coloring.
When you click on a file (or double-click if you have single-click
disabled), the OS looks up any application registered to handle an
input file with that extension. In the case of “.rb”, a properly
installed Ruby interpreter will be registered and it will be run with
that file as input. Since this was not done from within a console
window, the interpreter runs the program and immediately exits. Any
output is lost.
You run your Ruby source code file using the Ruby interpreter from a
console window (“Start:Accessories:Command Prompt” or cmd.exe). Within
the console window, run “ruby -v” to see if Ruby is on your application
path. If you get a “not recognized” error, insert the Ruby application
path into your path environment variable with
> PATH=\bin;%PATH%
Replace with the installation path on
your computer. For example:
> PATH=C:\Ruby193\bin;%PATH%
Change the current directory to where you saved your Ruby source code
file.
> cd
Now run the Ruby interpreter with your source code file:
> ruby
(Don’t forget to include the “.rb” extension if you saved it that way.)
The Ruby interpreter will interpret the give source code file and run
the program it describes, printing output text to the console window.
That should get you quickly up and running into the miserably documented
world of Ruby. Soon, you too will pine for those happy days when you
couldn’t even run it.
Enjoy!
Matthew R Chase wrote in post #1061485:
That reply would be better if it didn’t make a point of insulting
people.
??? Insulting? There is nothing in that reply that constitutes an
insult. The poor guy was lacking in information and now has all that he
needs. Ruby documentation is well known to be miserable, costing coders
and the software industry thousands of dollars in wasted man-hours
trying to learn how to do the simplest things.
These are simple statements of fact. Any insult you feel is your
problem, and way off topic in this thread. We’all just wanna code.
That reply would be better if it didn’t make a point of insulting
people.