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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A8751fed87d0bf9429940ccca9ffe02a?d=identicon&s=25 Alex (Guest)
on 2006-04-02 23:31
(Received via mailing list)
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
E17632fab00b930ea3b30e1b98f39675?d=identicon&s=25 Jeppe Jakobsen (Guest)
on 2006-04-02 23:58
(Received via mailing list)
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 <alex@alex.xom>:
2ee1a7960cc761a6e92efb5000c0f2c9?d=identicon&s=25 William James (Guest)
on 2006-04-03 01:05
(Received via mailing list)
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.)
4f0b71df92ecba6051d9524a60be4d93?d=identicon&s=25 Derek Perrault (Guest)
on 2006-04-03 01:14
(Received via mailing list)
Or you can still use SciTE to get the syntax coloring, but follow
William's
advice by only running your scripts in DOS.
4a8f467ac0763f4e75a39ea40fa1a30e?d=identicon&s=25 Alexandre (Guest)
on 2006-04-03 10:11
(Received via mailing list)
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
0b38637067b1f41993c8cccd1ec9fbbd?d=identicon&s=25 julian (Guest)
on 2006-04-03 13:55
(Received via mailing list)
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!
This topic is locked and can not be replied to.