Sorry very newbie post!

Ok so I just got myself Chris P.s book and started with the
questions in it and the first short prog I type in SciTE is

puts 'Hi, what`s your first name? ’
name = gets
puts 'your name is ’ + name

save it and run and get a command box which waits for me to exit and
then get the message
H what`s your first name?
Exit code: -1073741510
eh??. Not looking good!. (Tried it with RDE and even the i was
missing in that one?) . Chris wrote the book using Ruby version 1.8.2
and Im using 186-26 which is probably where the fault lies anyone suggest me where Im going wrong please?
Thanks
Steve

On Feb 22, 1:26 pm, Steve [email protected] wrote:

Ok so I just got myself Chris P.s book and started with the
questions in it and the first short prog I type in SciTE is

puts 'Hi, what`s your first name? ’
name = gets
puts 'your name is ’ + name

I know nothing about SciTE or RDE, so I’m assuming the problem has to
do with how you’re running your program from those editors. Try this:
save your 3-line program above into a file called hello.rb. Then, at
the command line, navigate to the directory containing that file, and
type:

ruby hello.rb

I bet your program will work properly. As to how to run it properly
from SciTE or RDE, I have no idea.

Tried that Karl and just get a quick flash of a command line
window???. Didnt think Id fall at the first fence ;-(, been reading
how good/easy Ruby is for the newbie. Are there better(?) editors
available for Ruby
Thanks
Steve

Steve wrote:

Tried that Karl and just get a quick flash of a command line
window???. Didnt think Id fall at the first fence ;-(, been reading
how good/easy Ruby is for the newbie. Are there better(?) editors
available for Ruby
Thanks
Steve

Not a Windows person, but it sounds like your ruby is a batch file
creating its own command window to run in. From the command prompt,
run:

ruby -e ‘puts “Hello”; sleep 5’

It should display “Hello” on the next line, wait 5 seconds and then give
you a prompt back.

If not, then you need to look at your Ruby installation…

You want to open a command prompt & run your program by passing it to
the ruby interpreter, like so (assuming windows):

c:\my_folder\ruby hello.rb

Also–I don’t think you want a backtick character here:

puts 'Hi, what`s your first name? ’

You want a single-quote/apostrophe:

puts 'Hi, what’s your first name? ’

HTH,

-Roy

On Feb 22, 2008, at 1:30 PM, Steve wrote:

Ok so I just got myself Chris P.s book and started with the
questions in it and the first short prog I type in SciTE is

puts 'Hi, what`s your first name? ’
what's
That \ is probably meant to escape the ’ inside a string literal that
uses ’ for delimiters.

You can generally use either ’ or " for string literals (the
differences will be made clear later in the book).

Try:

puts "Hi, what’s your first name? "

and Im using 186-26 which is probably where the fault lies anyone suggest me where Im going wrong please?
Thanks
Steve

I don’t have any idea why the ‘i’ fails to show unless it perhaps
isn’t really an ‘i’. Did you cut-n-paste from somewhere else? Might
there be some other character around that ‘i’?

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Steve wrote:

Ok so I just got myself Chris P.s book and started with the
questions in it and the first short prog I type in SciTE is

puts 'Hi, what`s your first name? ’
name = gets
puts 'your name is ’ + name

In Scite, the output is buffered. All output will be printed when your
program is finished. Very annoying. You can flush the buffer like this:

puts 'Hi, what`s your first name? ’
STDOUT.flush
name = gets # note you will get a name and a newline character here.
puts 'your name is ’ + name

Output will be printed in thew right pane of SciTE.

Regards,

Siep

As someone who is very new and just recently finished Chris’s book I
would
recommend the NetBeans IDE for Ruby (slimmed down version) … it’s a
very
easy way to write and run the code.

Regards,

Ashley

Thanks all for your helpful suggestions no doubt other anomalies will
crop up.
Cheers
Steve
Ps Ashley how did you find the book compared to the latest version of
Ruby?

I enjoyed the book, found it very easy to follow and the exercises make
you
think through problems and extrapolate on what you have learned.

I am on ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] with
Netbeans
6.1 and have not encountered any code that will not run (I didn’t do
everything in the book, just what appeared to be key).

It is fun, perhaps too much - it has consumed the past several weeks of
spare time.

I also played with Why’s poignant Guide http://poignantguide.net/ruby/

Try using what’s (single-quote) instead of what`s (back-tick).

Unless you want to print out a back-tick instead of single-quote, in
which case, you could just remove the back-slash.

So in the first case, you would do this:

puts 'Hi, what’s your first name? ’

In the second case, you would do this:

puts 'Hi, what`s your first name? ’

Hope that helps some.