Ok I have this figured out !
First to answer the questions: the error is thrown before entering the function.
About ThisStation and ThisDistance, you are right, but that was only a test I had made when looking for the source of the error and it was not the way the code was supposed to be (silly...