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

A

Alex

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
 
J

Jeppe Jakobsen

------=_Part_23450_18800615.1144014931520
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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.
 
W

William James

Alex said:
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.)
 
D

Derek Perrault

------=_Part_49_21666066.1144019633454
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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

n

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.)
s

------=_Part_49_21666066.1144019633454--
 
A

Alexandre

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
 
J

julian

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top