need help with subroutine

I agree with that in principle, but his ISR has to be able to get the most recent distance variable, it doesn't have time to calculate it on the spot. Hence the global variable.

Huh? What ISR?