From: "Llelan D." Date: 2012-05-21T15:24:35+09:00 Subject: Re: Having trouble with instructions in The Pragmatic Programmers Learn to Program 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 Program, 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! -- Posted via http://www.ruby-forum.com/.