From: Colin Bartlett Date: 2010-07-26T05:28:24+09:00 Subject: Re: basic beginner help needed --0016e65a022247b788048c3c1a52 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Sun, Jul 25, 2010 at 3:28 AM, Karl Halvorson w= rote: > I am new to Ruby and have been looking for some basic beginner help. I > have not been able to find a beginner forum anywhere, so I apologize if > this is too basic a question for this group. I have installed ruby > 1.9.1 on my windows 7 pc and have had success using interactive ruby > (and the Windows command prompt). Where I am stuck is creating a script > in notepad and then running that script. It seems a bit peculiar to me > that all the beginning tutorials that I have tried just say to create > these scripts, but they don=92t mention where they need to be saved. I > also have not come across any tutorials that cover configuring the ruby > file path. I believe I have written and named the scripts properly, but > when I try to open them, I get the error message: > > NameError: undefined local variable or method =91hello=92 for main:Objec= t > from (irb):1 > from C:/Ruby191/bin/irb:12:in =91
=92 > My apologies if the following is too elementary. I don't know how other users run Ruby programs from Microsoft Windows, but = I mostly use batch files. Or, to be precise, one batch file which takes various parameters to run different Ruby programs using different versions of Ruby. (There are some online utilities to help you do that, but I've temporarily forgotten what they are called!) A simple version is the following. Suppose you save your ruby program as progname.rb in C:\ruby_programs_directory\ or whatever you want to call the directory. (It doesn't have to be a directory in the root.) You can set up a Microsoft Windows batch file with the following command call "C:\ruby19\bin\ruby.exe" -v "C:\ruby_programs_directory\%1.rb" suppose we call that batch file rr.bat Then you can run the ruby program progname.rb by going into a Command Prompt window and typing. rr %1 Does that help any? (As X Heruacles said, if you post the script you have written, and also the commands you are using to try to run it, then we may eb able to give you a correction. From the error message, you are trying to run the script in IRB?) --0016e65a022247b788048c3c1a52--