SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is wrong with my little program.

    Code:
    print "What is your name? "
    name = gets
    puts " Your Name Is "
    puts name
    nfh = File.new(names.out", "w")
    nfh puts name
    nfh.close
    print "What Is your email Address?"
    email = gets
    puts " Your email Address is "
    puts email
    efh = File.new(email.out", "w")
    efh puts email
    efh.close
    print "What is your Age? "
    age = gets
    puts " You are "
    puts age
    puts " years of age "
    afh = File.new(age.out", "w")
    afh = puts age
    afh.close
    This is just a program im making to mess around with ruby and start to understand it more. Im sure all of you guys did dum programs like this I hope atleast :-P
    Well, What is wrong with it. It keeps getting me errors, its alot to type out in the errors, and i cant copy and paste it. Can yall either run it or just tell me what is wrong with it. and if so, show me a working code.

    What the program does and what im hopeing to make with it is
    storing the information in separate text files. That is all that i have done so far as you can see, but its not working :-P

    Then i am going to try and grab the info, and allow myself to edit it within the ruby window. Still dont know how im going to do all of that

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Missing opening qutoes on all of your file names?

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think that is it is there anything else?

  4. #4
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Missing opening quotes is definitely an error

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know, I was stating that that is not all of the problem here is my updated code
    Code:
     
    print "What is your name? "
    name = gets
    puts " Your Name Is "
    puts name
    nfh = File.new("names.out", "w")
    nfh puts name
    nfh.close
    print "What Is your email Address?"
    email = gets
    puts " Your email Address is "
    puts email
    efh = File.new("email.out", "w")
    efh puts email
    efh.close
    print "What is your Age? "
    age = gets
    puts " You are "
    puts age
    puts " years of age "
    afh = File.new("age.out", "w")
    afh = puts age
    afh.close

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, i got it to work now, It was quotations but it was also something else. That i just forgot to do i mean left out. notice how i put
    efh puts email
    it should have been efh.puts email So that was where i ed up as well with the quotes :-P Thanks for your help guys Greatly appreciated


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •