When I open up Ruby on my Windows Desktop and I write code, how do I get it
to compile? I am new to Ruby and programming.
Help.
When I open up Ruby on my Windows Desktop and I write code, how do I get it
to compile? I am new to Ruby and programming.
Help.
When I open up Ruby on my Windows Desktop and I write code, how do I get it
to compile? I am new to Ruby and programming.
Ruby programs are interpreted, not compiled. The source code is passed directly
to the Ruby interpreter (ruby.exe on Windows, probably located in c:\ruby\bin).
The interpreter then examines the source code and executes it (or complains abut
errors).
If, for example, you have a ruby script named my_script.rb in directory
c:\my_code, you can execute it by calling the ruby interpreter from a CMD shell
window:
C:\my_code> ruby my_script.rb
Certain versions of Windows (Windows 2000, for instance) allow file associations
that work from the command line, and if you’ve installed Ruby using the version
from the Pragmatic Programmer site you may be able to call the script without
explicitly naming the interpreter:
C:\my_code> my_script.rb
You should also be able to double-click a file in Windows Explorer, which
should launch the interpreter and execute the script, but, by and large, Ruby
scripts are command-line focused. Running a ruby program from Windows Explorer
may cause a CMD shell window to flash briefly, then immediately go away.
I believe the Scite editor allows one to run code directly in place, but I don’t
use Scite, so I can’t help there.
On Windows, I generally edit code using Vim, and execute programs from a CMD
shell window, or from Vim itself. Makes it less distracting when I switch to
developing on Linux.
James
“Regina Goodwin” amanishakhete@earthlink.net wrote in message news:icCt9.728$6F4.61145@newsread2.prod.itd.earthlink.net…
When I open up Ruby on my Windows Desktop and I write code, how do I get it
to compile? I am new to Ruby and programming.Help
There’s no need to compile it because it’s a script language. The Ruby
files work just like VBScript files; you can just write your script
using Notepad, save the file with a “.rb” extension, and double-click
it to run it. I’m also using Ruby with Windows, and I’m fairly
inexperienced at it, so I feel your pain because I went through your
confusion at the beginning. Have you already downloaded and run the
Ruby for Windows installation? You should be able to click
“Start>Programs>Ruby” and see a number of programs, like “Interactive
Ruby Shell,” “RubyBook Help,” and “RubyWin.” If you don’t even see
that, then you need to download the installation and run it. Here’s
one place to get it:
http://www.s-direktnet.de/homepages/neumann/rb_prgs/
If you do have Ruby installed and you can see those programs, I found
the easiest place to start learning Ruby is the “RubyWin” program.
Click Start>Programs>Ruby>RubyWin to start the RubyWin program. You
can use this program to write and run your Ruby scripts. For example,
let’s say you’ve written a Ruby script and saved it as an *.rb file,
and now you want to run it. To do so, click Ruby>Run File and browse
to the file, then click Open and the script will be run. If there are
errors, you’ll be able to see the errors that are occurring. You can
now open that file with File>Open, fix the errors and save the file,
then click Ruby>Run File and browse to the file again to re-run it.
You can also double-click on an *.rb file directly and it will run,
because the Ruby installation makes an association with the “.rb” file
extension. However, if your Ruby code just does something like write
the word “test” back to the screen (for example, if your Ruby script
just has this one line of code: puts ‘test’), then you’ll just see a
momentary flash as the Ruby shell quickly opens, runs, and closes. It
can be confusing because it seems like nothing’s happening. Also, if
there are errors, you won’t be able to read them because the shell
closes right away. That’s why I find it better to run files using the
RubyWin program.
Here’s a basic example that shows how a Ruby script can actually do
things like create Windows files. Try putting these two lines in a
text file and save the file with the name test.rb:
aFile=File.new(“c:\temp\test.txt”, “w”)
aFile.close
When you double-click on the “test.rb” file, it should create the
“test.txt” file in your temp directory.
In addition to what James T. and James B. have said: There is a fairly
stable (and easy-to-use) compiler that allows you to “compile” Ruby
scripts into Windows executables. Download link and information are
located at this URL: http://www.ruby-lang.org/en/raa-list.rhtml?id=700
-M.
On Wed, 23 Oct 2002 18:50:54 GMT, “Regina Goodwin” amanishakhete@earthlink.net wrote:
When I open up Ruby on my Windows Desktop and I write code, how do I get it
to compile?
–
To e-mail: use the initials of my name and add “at felinism dot com”.
Hi,
At Thu, 24 Oct 2002 04:34:46 +0900, JamesBritt wrote:
You should also be able to double-click a file in Windows Explorer, which
should launch the interpreter and execute the script, but, by and large, Ruby
scripts are command-line focused. Running a ruby program from Windows Explorer
may cause a CMD shell window to flash briefly, then immediately go away.
You can compile GUI mode rubyw.exe, but I’m not sure if Windows
Installer version contains it.
And there’s DronOnScript, a utility allows DnD to scripts,
though it’s only japanese version.
http://www3.ocn.ne.jp/~yamako/Others/DropOnScript.html
–
Nobu Nakada