analyzer.rb cannot run.

Discussion in 'Ruby' started by Genocide Law, Feb 3, 2009.

  1. Genocide Law

    Genocide Law Guest

    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/.
     
    Genocide Law, Feb 3, 2009
    #1
    1. Advertising

  2. 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/.
     
    Brian Candler, Feb 3, 2009
    #2
    1. Advertising

  3. Genocide Law

    Genocide Law Guest

    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/.
     
    Genocide Law, Feb 3, 2009
    #3
  4. Genocide Law

    Todd Benson Guest

    On Tue, Feb 3, 2009 at 8:46 AM, Genocide Law <> 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
     
    Todd Benson, Feb 3, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Gutzler

    search for netnames in design analyzer

    Thomas Gutzler, Dec 18, 2003, in forum: VHDL
    Replies:
    1
    Views:
    569
    davidjaffer666
    Nov 29, 2010
  2. J Gao
    Replies:
    0
    Views:
    1,229
    J Gao
    Jul 28, 2003
  3. Seung Soo, Ha

    Run clang static analyzer on Python 3.30a

    Seung Soo, Ha, Aug 10, 2011, in forum: Python
    Replies:
    0
    Views:
    213
    Seung Soo, Ha
    Aug 10, 2011
  4. Replies:
    2
    Views:
    144
  5. Tony Mr
    Replies:
    1
    Views:
    91
    Quintus
    Jul 31, 2010
Loading...

Share This Page