I'm new to Ruby, having worked with Perl the past couple of years.  I'm
having trouble calling a method to increment a counter, and I'm assuming
that the problem is with the scope of the variables?

I'm getting the following error message:
P:/PETERV2/scripts/vlog2.rb:25:in `test_meth1': undefined method `+' for
nil:NilClass (NoMethodError)
  from P:/PETERV2/scripts/vlog2.rb:47
  from P:/PETERV2/scripts/vlog2.rb:36:in `each'
  from P:/PETERV2/scripts/vlog2.rb:36
  from P:/PETERV2/scripts/vlog2.rb:7:in `open'
  from P:/PETERV2/scripts/vlog2.rb:7

This is the method I'm trying to call:
def test_meth1
   counter = counter + 1
   return counter
end

This is the call:

          case typrec                             # case statement
example.
             when "TR001"
                 cntr = test_meth1
                 puts cntr  # Here I want to print the counter value.
             when "AB001"
                ab001 += 1
             when "AI001"
                ai001 += 1
             else
                puts "Invalid message type"
          end

I assume that there's a really simple mistake I'm making, so any help
would be greatly appreciated.

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