[lnkForumImage]
TotalShareware - Download Free Software

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


 

Morton Goldberg

4/17/2007 6:59:00 PM

On Apr 17, 2007, at 1:22 PM, poison tooth wrote:

> Im just learning ruby and im stuck the guide im using says
>
> "Your first program
> Congratulations! Now that you have made it this far, you are ready to
> start writing programs.
> Hello World
> Grab a text editor and type in the following:
>
> puts "Hello World"
>
> Save the file as hello.rb and run it by typing
> ruby hello.rb"
>
> i've tried that more than once and it says the out is:
>
> "irb(main):001:0> ruby hello.rb
> NameError: undefined local variable or method `hello' for main:Object
> from (irb):1
> irb(main):002:0> "
>
> the guide never said what word processor should i use
> i tried TextEdit.app but it fussed about the .rb
> so i used Microsoft word and this is what it does...
>
> Any tips?

Since you mention TextEdit, I presume you are on a Mac. Also, since
you mention irb, I presume you are familiar with Terminal. Here is an
easy way to run a Ruby script in Terminal. After writing your hello
script in TextEdit save it as hello.rb. Now in terminal at a fresh
prompt, type "ruby " (without the quotes and remember to include the
space after "ruby"). Now drag hello.rb into to Terminal and hit
return. The text "Hello World" should appear.

Regards, Morton

8 Answers

Morton Goldberg

4/17/2007 7:23:00 PM

0

On Apr 17, 2007, at 2:59 PM, Morton Goldberg wrote:

> On Apr 17, 2007, at 1:22 PM, poison tooth wrote:
>
>> Im just learning ruby and im stuck the guide im using says
>>
>> "Your first program
>> Congratulations! Now that you have made it this far, you are ready to
>> start writing programs.
>> Hello World
>> Grab a text editor and type in the following:
>>
>> puts "Hello World"
>>
>> Save the file as hello.rb and run it by typing
>> ruby hello.rb"
>>
>> i've tried that more than once and it says the out is:
>>
>> "irb(main):001:0> ruby hello.rb
>> NameError: undefined local variable or method `hello' for main:Object
>> from (irb):1
>> irb(main):002:0> "
>>
>> the guide never said what word processor should i use
>> i tried TextEdit.app but it fussed about the .rb
>> so i used Microsoft word and this is what it does...
>>
>> Any tips?
>
> Since you mention TextEdit, I presume you are on a Mac. Also, since
> you mention irb, I presume you are familiar with Terminal. Here is
> an easy way to run a Ruby script in Terminal. After writing your
> hello script in TextEdit save it as hello.rb. Now in terminal at a
> fresh prompt, type "ruby " (without the quotes and remember to
> include the space after "ruby"). Now drag hello.rb into to Terminal
> and hit return. The text "Hello World" should appear.

Also, there is one more possible source of trouble. TextEdit must be
in Plain Text mode when you save a Ruby script. If it's in Rich Text
mode, hit cmnd-shift-T to change the mode before you save.

Regards, Morton

poison tooth

4/17/2007 10:23:00 PM

0

oh ok
i think i know where i made my mistake
thanks
On 4/17/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:
> On Apr 17, 2007, at 2:59 PM, Morton Goldberg wrote:
>
> > On Apr 17, 2007, at 1:22 PM, poison tooth wrote:
> >
> >> Im just learning ruby and im stuck the guide im using says
> >>
> >> "Your first program
> >> Congratulations! Now that you have made it this far, you are ready to
> >> start writing programs.
> >> Hello World
> >> Grab a text editor and type in the following:
> >>
> >> puts "Hello World"
> >>
> >> Save the file as hello.rb and run it by typing
> >> ruby hello.rb"
> >>
> >> i've tried that more than once and it says the out is:
> >>
> >> "irb(main):001:0> ruby hello.rb
> >> NameError: undefined local variable or method `hello' for main:Object
> >> from (irb):1
> >> irb(main):002:0> "
> >>
> >> the guide never said what word processor should i use
> >> i tried TextEdit.app but it fussed about the .rb
> >> so i used Microsoft word and this is what it does...
> >>
> >> Any tips?
> >
> > Since you mention TextEdit, I presume you are on a Mac. Also, since
> > you mention irb, I presume you are familiar with Terminal. Here is
> > an easy way to run a Ruby script in Terminal. After writing your
> > hello script in TextEdit save it as hello.rb. Now in terminal at a
> > fresh prompt, type "ruby " (without the quotes and remember to
> > include the space after "ruby"). Now drag hello.rb into to Terminal
> > and hit return. The text "Hello World" should appear.
>
> Also, there is one more possible source of trouble. TextEdit must be
> in Plain Text mode when you save a Ruby script. If it's in Rich Text
> mode, hit cmnd-shift-T to change the mode before you save.
>
> Regards, Morton
>
>


--
fish can't fly but birds can
birds can't swim but fish can

poison tooth

4/17/2007 10:29:00 PM

0

oh
now i got this...

h-68-164-42-185:~ stefan$ ruby ruby.rb
ruby: No such file or directory -- ruby.rb (LoadError)
h-68-164-42-185:~ stefan$ cd documents
h-68-164-42-185:~/documents stefan$ ruby hello.rb
hello.rb:1: Invalid char `\320' in expression
hello.rb:1: Invalid char `\317' in expression
hello.rb:1: Invalid char `\021' in expression
hello.rb:1: Invalid char `\340' in expression
hello.rb:1: Invalid char `\241' in expression
hello.rb:1: Invalid char `\261' in expression
h-68-164-42-185:~/documents stefan$

do i need to get into irb then out and then do it?



On 4/17/07, smc smc <fixxie.wits@gmail.com> wrote:
> oh ok
> i think i know where i made my mistake
> thanks
> On 4/17/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:
> > On Apr 17, 2007, at 2:59 PM, Morton Goldberg wrote:
> >
> > > On Apr 17, 2007, at 1:22 PM, poison tooth wrote:
> > >
> > >> Im just learning ruby and im stuck the guide im using says
> > >>
> > >> "Your first program
> > >> Congratulations! Now that you have made it this far, you are ready to
> > >> start writing programs.
> > >> Hello World
> > >> Grab a text editor and type in the following:
> > >>
> > >> puts "Hello World"
> > >>
> > >> Save the file as hello.rb and run it by typing
> > >> ruby hello.rb"
> > >>
> > >> i've tried that more than once and it says the out is:
> > >>
> > >> "irb(main):001:0> ruby hello.rb
> > >> NameError: undefined local variable or method `hello' for main:Object
> > >> from (irb):1
> > >> irb(main):002:0> "
> > >>
> > >> the guide never said what word processor should i use
> > >> i tried TextEdit.app but it fussed about the .rb
> > >> so i used Microsoft word and this is what it does...
> > >>
> > >> Any tips?
> > >
> > > Since you mention TextEdit, I presume you are on a Mac. Also, since
> > > you mention irb, I presume you are familiar with Terminal. Here is
> > > an easy way to run a Ruby script in Terminal. After writing your
> > > hello script in TextEdit save it as hello.rb. Now in terminal at a
> > > fresh prompt, type "ruby " (without the quotes and remember to
> > > include the space after "ruby"). Now drag hello.rb into to Terminal
> > > and hit return. The text "Hello World" should appear.
> >
> > Also, there is one more possible source of trouble. TextEdit must be
> > in Plain Text mode when you save a Ruby script. If it's in Rich Text
> > mode, hit cmnd-shift-T to change the mode before you save.
> >
> > Regards, Morton
> >
> >
>
>
> --
> fish can't fly but birds can
> birds can't swim but fish can
>
>


--
fish can't fly but birds can
birds can't swim but fish can

Phillip Gawlowski

4/17/2007 10:46:00 PM

0

smc smc wrote:
> oh
> now i got this...
>
> h-68-164-42-185:~ stefan$ ruby ruby.rb
> ruby: No such file or directory -- ruby.rb (LoadError)
> h-68-164-42-185:~ stefan$ cd documents
> h-68-164-42-185:~/documents stefan$ ruby hello.rb
> hello.rb:1: Invalid char `\320' in expression
> hello.rb:1: Invalid char `\317' in expression
> hello.rb:1: Invalid char `\021' in expression
> hello.rb:1: Invalid char `\340' in expression
> hello.rb:1: Invalid char `\241' in expression
> hello.rb:1: Invalid char `\261' in expression
> h-68-164-42-185:~/documents stefan$
>
> do i need to get into irb then out and then do it?

Firstly:
A: Because it makes it difficult to associate responses.
Q: Why is top posting bad?

Secondly: Save your script as a text file, not as a binary.

--
Phillip "CynicalRyan" Gawlowski
http://cynicalryan....
http://clothred.rub...

Rule of Open-Source Programming #34:

Every successful project will eventually spawn a sub-project

noah.easterly@gmail.com

4/17/2007 11:23:00 PM

0

On Apr 17, 6:28 pm, "smc smc" <fixxie.w...@gmail.com> wrote:
> oh
> now i got this...
>
> h-68-164-42-185:~ stefan$ ruby ruby.rb
> ruby: No such file or directory -- ruby.rb (LoadError)
> h-68-164-42-185:~ stefan$ cd documents
> h-68-164-42-185:~/documents stefan$ ruby hello.rb
> hello.rb:1: Invalid char `\320' in expression
> hello.rb:1: Invalid char `\317' in expression
> hello.rb:1: Invalid char `\021' in expression
> hello.rb:1: Invalid char `\340' in expression
> hello.rb:1: Invalid char `\241' in expression
> hello.rb:1: Invalid char `\261' in expression
> h-68-164-42-185:~/documents stefan$
>
> do i need to get into irb then out and then do it?

Nope, it looks like the file wasn't saved as plain text. I'm guessing
you tried saving it from Word, like you said earlier. I don't know
how to save as plain text in Word, so I'll show you how to do it
another way.

Open your file in TextEdit. If TextEdit can't open the old file, it
might be having problems with the MS format, just delete the old one
and start a new file in TextEdit, and enter your ruby code. Make sure
you hit return at the end of your file ( this is just so we can view
it with the cat command later ).

Unless you have converted the file to plain text, TextEdit won't let
you save it as a ".rb" file. So, first, go to "Format->Make Plain
Text" (if you only see "Make Rich Text", then it's already plain
text). If it asks you whether to convert the file to plain text,
click OK. Then save the file as "hello.rb". TextEdit will probably
pop up with a message saying 'You have used the extension ".rb" at the
end of the name. The standard extension is ".txt". Click the button
that says "Use .rb". (

Now, you can check from the command line that your file is actually
plain text, by using the "cat" command.

h-68-164-42-185:~/documents stefan$ cat hello.rb
puts "Hello World"

And now you can run it.

h-68-164-42-185:~/documents stefan$ ruby hello.rb
Hello World

Later on, you might want to consider getting a "real" text editor to
help you write ruby code. They'll do things that Word & TextEdit
don't that make it easier to write good code. Features like syntax
highlighting and auto-indentation are two of the ways that "real" text
editors help coders catch errors early on.

I'm not going to tell you which one to use. If you ask any
programmer, anywhere on the web, they'll tell you which they use, and
why it's the one you should use. You might want to check out the
wikipedia article (http://en.wikipedia.org/wiki/Te...), as that
might give you some good leads.

But, I wouldn't get too sidetracked by looking for an editor.
TextEdit (in plain text mode) should be good enough to get you through
the basic tutorials.

poison tooth

4/18/2007 12:41:00 AM

0

thanks
i finally got it!!!


On 4/17/07, Noah Easterly <noah.easterly@gmail.com> wrote:
> On Apr 17, 6:28 pm, "smc smc" <fixxie.w...@gmail.com> wrote:
> > oh
> > now i got this...
> >
> > h-68-164-42-185:~ stefan$ ruby ruby.rb
> > ruby: No such file or directory -- ruby.rb (LoadError)
> > h-68-164-42-185:~ stefan$ cd documents
> > h-68-164-42-185:~/documents stefan$ ruby hello.rb
> > hello.rb:1: Invalid char `\320' in expression
> > hello.rb:1: Invalid char `\317' in expression
> > hello.rb:1: Invalid char `\021' in expression
> > hello.rb:1: Invalid char `\340' in expression
> > hello.rb:1: Invalid char `\241' in expression
> > hello.rb:1: Invalid char `\261' in expression
> > h-68-164-42-185:~/documents stefan$
> >
> > do i need to get into irb then out and then do it?
>
> Nope, it looks like the file wasn't saved as plain text. I'm guessing
> you tried saving it from Word, like you said earlier. I don't know
> how to save as plain text in Word, so I'll show you how to do it
> another way.
>
> Open your file in TextEdit. If TextEdit can't open the old file, it
> might be having problems with the MS format, just delete the old one
> and start a new file in TextEdit, and enter your ruby code. Make sure
> you hit return at the end of your file ( this is just so we can view
> it with the cat command later ).
>
> Unless you have converted the file to plain text, TextEdit won't let
> you save it as a ".rb" file. So, first, go to "Format->Make Plain
> Text" (if you only see "Make Rich Text", then it's already plain
> text). If it asks you whether to convert the file to plain text,
> click OK. Then save the file as "hello.rb". TextEdit will probably
> pop up with a message saying 'You have used the extension ".rb" at the
> end of the name. The standard extension is ".txt". Click the button
> that says "Use .rb". (
>
> Now, you can check from the command line that your file is actually
> plain text, by using the "cat" command.
>
> h-68-164-42-185:~/documents stefan$ cat hello.rb
> puts "Hello World"
>
> And now you can run it.
>
> h-68-164-42-185:~/documents stefan$ ruby hello.rb
> Hello World
>
> Later on, you might want to consider getting a "real" text editor to
> help you write ruby code. They'll do things that Word & TextEdit
> don't that make it easier to write good code. Features like syntax
> highlighting and auto-indentation are two of the ways that "real" text
> editors help coders catch errors early on.
>
> I'm not going to tell you which one to use. If you ask any
> programmer, anywhere on the web, they'll tell you which they use, and
> why it's the one you should use. You might want to check out the
> wikipedia article (http://en.wikipedia.org/wiki/Te...), as that
> might give you some good leads.
>
> But, I wouldn't get too sidetracked by looking for an editor.
> TextEdit (in plain text mode) should be good enough to get you through
> the basic tutorials.
>
>
>


--
fish can't fly but birds can
birds can't swim but fish can

John Joyce

4/18/2007 3:06:00 AM

0

while you are at it, get the book "learning unix for OS X Tiger"
You're going to need a few unix skills here. Not a lot, but it will
help you understand stuff more.
If you need more, get Unix In a Nutshell (it covers OS X, Linux, Unix)
On Apr 18, 2007, at 9:40 AM, smc smc wrote:

> thanks
> i finally got it!!!
>
>
> On 4/17/07, Noah Easterly <noah.easterly@gmail.com> wrote:
>> On Apr 17, 6:28 pm, "smc smc" <fixxie.w...@gmail.com> wrote:
>> > oh
>> > now i got this...
>> >
>> > h-68-164-42-185:~ stefan$ ruby ruby.rb
>> > ruby: No such file or directory -- ruby.rb (LoadError)
>> > h-68-164-42-185:~ stefan$ cd documents
>> > h-68-164-42-185:~/documents stefan$ ruby hello.rb
>> > hello.rb:1: Invalid char `\320' in expression
>> > hello.rb:1: Invalid char `\317' in expression
>> > hello.rb:1: Invalid char `\021' in expression
>> > hello.rb:1: Invalid char `\340' in expression
>> > hello.rb:1: Invalid char `\241' in expression
>> > hello.rb:1: Invalid char `\261' in expression
>> > h-68-164-42-185:~/documents stefan$
>> >
>> > do i need to get into irb then out and then do it?
>>
>> Nope, it looks like the file wasn't saved as plain text. I'm
>> guessing
>> you tried saving it from Word, like you said earlier. I don't know
>> how to save as plain text in Word, so I'll show you how to do it
>> another way.
>>
>> Open your file in TextEdit. If TextEdit can't open the old file, it
>> might be having problems with the MS format, just delete the old one
>> and start a new file in TextEdit, and enter your ruby code. Make
>> sure
>> you hit return at the end of your file ( this is just so we can view
>> it with the cat command later ).
>>
>> Unless you have converted the file to plain text, TextEdit won't let
>> you save it as a ".rb" file. So, first, go to "Format->Make Plain
>> Text" (if you only see "Make Rich Text", then it's already plain
>> text). If it asks you whether to convert the file to plain text,
>> click OK. Then save the file as "hello.rb". TextEdit will probably
>> pop up with a message saying 'You have used the extension ".rb" at
>> the
>> end of the name. The standard extension is ".txt". Click the button
>> that says "Use .rb". (
>>
>> Now, you can check from the command line that your file is actually
>> plain text, by using the "cat" command.
>>
>> h-68-164-42-185:~/documents stefan$ cat hello.rb
>> puts "Hello World"
>>
>> And now you can run it.
>>
>> h-68-164-42-185:~/documents stefan$ ruby hello.rb
>> Hello World
>>
>> Later on, you might want to consider getting a "real" text editor to
>> help you write ruby code. They'll do things that Word & TextEdit
>> don't that make it easier to write good code. Features like syntax
>> highlighting and auto-indentation are two of the ways that "real"
>> text
>> editors help coders catch errors early on.
>>
>> I'm not going to tell you which one to use. If you ask any
>> programmer, anywhere on the web, they'll tell you which they use, and
>> why it's the one you should use. You might want to check out the
>> wikipedia article (http://en.wikipedia.org/wiki/Te...), as
>> that
>> might give you some good leads.
>>
>> But, I wouldn't get too sidetracked by looking for an editor.
>> TextEdit (in plain text mode) should be good enough to get you
>> through
>> the basic tutorials.
>>
>>
>>
>
>
> --
> fish can't fly but birds can
> birds can't swim but fish can
>


benjohn

4/18/2007 7:43:00 PM

0


On 18 Apr 2007, at 01:40, smc smc wrote:

> thanks
> i finally got it!!!

:-) Congratulations. I hope you have a lot of fun.