[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Sorry very newbie post!

Steve

2/22/2008 6:26:00 PM

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

10 Answers

Karl von Laudermann

2/22/2008 6:47:00 PM

0

On Feb 22, 1:26 pm, Steve <stevec...@btinternet.com> wrote:
> 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.

Steve

2/22/2008 6:53:00 PM

0

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

rpardee@gmail.com

2/22/2008 7:11:00 PM

0

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, 10:53 am, Steve <stevec...@btinternet.com> wrote:
> 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

Mark Bush

2/22/2008 7:11:00 PM

0

Steve wrote:
> 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...

--
Posted via http://www.ruby-....

John Woods

2/22/2008 7:19:00 PM

0

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


Rob Biedenharn

2/22/2008 7:25:00 PM

0

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

> 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://agileconsult...
Rob@AgileConsultingLLC.com

Siep Korteling

2/22/2008 8:49:00 PM

0

Steve wrote:
> 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

--
Posted via http://www.ruby-....

Ashley Wharton

2/23/2008 12:21:00 AM

0

[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

On Fri, Feb 22, 2008 at 1:30 PM, Steve <stevecuth@btinternet.com> wrote:

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

Steve

2/23/2008 12:40:00 PM

0

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?

Ashley Wharton

2/23/2008 1:55:00 PM

0

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





On Sat, Feb 23, 2008 at 7:39 AM, Steve <stevecuth@btinternet.com> wrote:

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