Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > analyzer.rb cannot run.

Reply
Thread Tools

analyzer.rb cannot run.

 
 
Genocide Law
Guest
Posts: n/a
 
      02-03-2009
Hi, I'm kinda new to this programmin thing and I'm currently using
windows vista and it seems whenever I run this file:

line = File.readlines("text.txt")
lines_count = lines.size
text = lines.join
puts "#{line_count} lines"

It will show :

>ruby C:/Users/administrator/analyzer.rb

*** WARNING *** Windows users should check the "Run process in terminal"
check box in the Debugger Preferences
to see STDOUT and STDERR output in real time.

C:/Users/administrator/analyzer.rb:2: undefined local variable or method
`lines' for main:Object (NameError)
>exit


and as you can see, there's an error in the code but I can't seem to
find out what. I have attached the text maybe someone can run it and
tell me what's wrong?

Thanks,

Gen

Attachments:
http://www.ruby-forum.com/attachment/3248/text.txt

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

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      02-03-2009
Genocide Law wrote:
> Hi, I'm kinda new to this programmin thing and I'm currently using
> windows vista and it seems whenever I run this file:
>
> line = File.readlines("text.txt")
> lines_count = lines.size
> text = lines.join
> puts "#{line_count} lines"
>
> It will show :
>
>>ruby C:/Users/administrator/analyzer.rb

> *** WARNING *** Windows users should check the "Run process in terminal"
> check box in the Debugger Preferences
> to see STDOUT and STDERR output in real time.
>
> C:/Users/administrator/analyzer.rb:2: undefined local variable or method
> `lines' for main:Object (NameError)
>>exit

>
> and as you can see, there's an error in the code but I can't seem to
> find out what. I have attached the text maybe someone can run it and
> tell me what's wrong?


The error message does tell you exactly the problem: it's on line 2 of
analyzer.rb, and the problem is that you referred to something called
"lines" but no such thing exists. That is, there is no local variable or
method called "lines"

On line 1 you created a local variable called "line", not "lines"

HTH,

Brian.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Genocide Law
Guest
Posts: n/a
 
      02-03-2009
Ha ha, okay, I realized now. I copied the codes wrong too. Anyhow, I got
it done awhile ago. Thankx yeah!

P.S. what does HTH means.... -.-

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

 
Reply With Quote
 
Todd Benson
Guest
Posts: n/a
 
      02-03-2009
On Tue, Feb 3, 2009 at 8:46 AM, Genocide Law <(E-Mail Removed)> wrote:
> Ha ha, okay, I realized now. I copied the codes wrong too. Anyhow, I got
> it done awhile ago. Thankx yeah!
>
> P.S. what does HTH means.... -.-


In this group, it usually means "hope that helps", or "hope that helped".

You can google internet acronyms to see some others in use. There's
also a wiktionary page dedicated to such a thing:

http://en.wiktionary.org/wiki/Appendix:Internet_slang

Todd

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Copy Assembly <MyAssembly> The Process Cannot Access The File Because It Is Being Used By Another Process Ram ASP .Net 2 06-30-2005 11:30 AM
Cannot delete file from webserver...... process cannot access style error news.microsoft.com ASP .Net 4 01-10-2005 06:07 AM
BOOT GENERIC virus -- cannot clean; cannot delete. Please help! wgreene Computer Support 4 08-13-2004 12:21 AM
Browser cannot find any server anymore after 5 minutes of normal activity (" The page cannot be displayed ") reply@newsgroup.please Computer Support 6 01-05-2004 04:03 AM
The file 'bin\WebProj.dll' cannot be copied to the run directory. The requested operation cannot be performed on a file with a user-mapped section open. J Gao ASP .Net 0 07-28-2003 04:18 PM



Advertisments