INSTRUCTING ARDUINO TO RECALL A PREVIOUSLY GIVEN VALUE

I showed you how to create a global distance variable in the other thread. Provided you don't also define local versions of distance, it will do what you want.

Here it is again:

int distance;

void setup()
{
// code can use distance here.
}

void loop()
{
// code can use distance here too.
}

void anotherFunction()
{
// and here too.
}