Newby>> Ruby and method Gets... and Windows

Hi,

i’m under Windows XP SP2 and i installed OneClick Installer. So, i began
to
read some documentations and i learnt to use the gets’s method.

So nothing hard in that, i wrote my program in SciTE:

puts “Hi what’s your name?”
nom = gets
puts "OK Hi " + nom

But it don’t work. A windows with “c:\ruby\bin\ruby.exe” in the titlebar
appear but i can’t write anything in it. Nothing. So i close the windows
and
in SciTE i have it:
Exit code: -1073741510

Can you help me please? And please, don’t tell me i have to work under
Linux
;o)

Thanks

Alex

Well don’t worry you don’t have to switch to Linux.
When running programs which use “gets”, you have to use your command
line.

2006/4/2, Alex [email protected]:

Alex wrote:

Hi,

i’m under Windows XP SP2 and i installed OneClick Installer. So, i began to
read some documentations and i learnt to use the gets’s method.

So nothing hard in that, i wrote my program in SciTE:

Don’t use SciTE. It isn’t part of Ruby. Use your favorite text
editor (even Notepad). Save the program as “name.rb” and run it
from the DOS prompt with

ruby name.rb

(To open a DOS prompt, click on
Start / Programs / Accessories / Command prompt.)

Or you can still use SciTE to get the syntax coloring, but follow
William’s
advice by only running your scripts in DOS.

Hi,

thanks for your answer, actually, i found it after my message. But on
Windows, in command prompt, you have to be in the directory which
contain
the program.
I havec to type:
cd
cd mysampledir\ex1
ruby name.rb

And it works!

Thanks

I have found just the same thing myself… You can use SciTE to write
the ruby program, and do make sure you give it a .rb extenstion, and do
make sure that you save it before running it. But when is comes to
running it you should run it from inside the command prompt, not from
inside sciTE. If the program has no lines in it using gets then it will
probably run in SciTE, but if you are using gets then run it in the
cmd prompt.
The other interesting things are :
1 what if you want to put the ruby program in to a part of rails, and
where and how to do this…
You can put ruby code into parts of rails but you should surround the
ruby code with <%= and %> I think, and of course you must have a ruby
server running on the machine that you have the file on, otherwise no
ruby code will be interprested at all!