Catherine Moroney wrote: > Writing a function seems to work though. Or is there a problem with > this solution that I don't know? Don't even open that bag of worms. The short answer: Do not use a function for this, use a subroutine. Functions are not guaranteed to be executed: a=f(x)+f(x) is x incremented twice or once, i.e., how many times is f really called??? Aleks