From: "Darren H." Date: 2011-11-13T07:59:44+09:00 Subject: Re: Syntax Error test.rb:14:in `block in
': undefined local variable or method `price' for main:Object (NameError) from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1768:in `each' from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1202:in `block in foreach' from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1340:in `open' from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1201:in `foreach' from test.rb:12:in `
' #error i have... #new code puts "Enter Product ID Number" product_id = gets.chomp CSV.foreach("c:\plantproducts.csv") do |row| if product_id == row[0] (price*qty) == subtotal puts "Enter Quantity" quantity = gets.chomp end end subtotal = (price * quantity) puts subtotal I don't understand why price is an unidentified variable... is the current code not reading it in the CSV file and giving it as an output? -- Posted via http://www.ruby-forum.com/.