Tim Hunter wrote: > Peter Vanderhaden wrote: >> from P:/PETERV2/scripts/vlog2.rb:7:in `open' >> case typrec # case statement >> end >> >> I assume that there's a really simple mistake I'm making, so any help >> would be greatly appreciated. >> >> > You never initialize the 'counter' variable so it's default value is > nil. Ruby is telling you that there is no "+" method for a nil object, > that is, you can't add 1 to nil. > > If "test_meth1" were in a class, you could make counter be an instance > variable and initialize it in the initialize method. Since it's not, > it'll have to be a global variable. Global variable names start with $. > > $counter = 0 > def test > $counter = $counter + 1 > return $counter > end Tim, Thanks very much for the response! I've got it working now. Peter V. -- Posted via http://www.ruby-forum.com/.