Sorry very newbie post!

S

Steve

Ok so I just got myself Chris Pines 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 I`m using 186-26 which is probably where the fault lies anyone
suggest me where I`m going wrong please?
Thanks
Steve
 
K

Karl von Laudermann

Ok so I just got myself Chris Pines 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.
 
S

Steve

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

rpardee

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
 
M

Mark Bush

Steve said:
Tried that Karl and just get a quick flash of a command line
window???. Didn`t think I`d 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...
 
J

John Woods

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.


-----Original Message-----
From: Steve
Sent: 02/22/2008 10:30 AM
 
R

Rob Biedenharn

Ok so I just got myself Chris Pines 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? "
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 I`m using 186-26 which is probably where the fault lies anyone
suggest me where I`m 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 Biedenharn http://agileconsultingllc.com
(e-mail address removed)
 
S

Siep Korteling

Steve said:
Ok so I just got myself Chris Pines 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
 
A

Ashley Wharton

[Note: parts of this message were removed to make it a legal post.]

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
 
S

Steve

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?
 
A

Ashley Wharton

[Note: parts of this message were removed to make it a legal post.]

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/
 

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

Members online

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,420
Latest member
ZitaVos505

Latest Threads

Top