INSTRUCTING ARDUINO TO RECALL A PREVIOUSLY GIVEN VALUE

If you want a global variable, declare it at the top of the sketch before your setup() and loop() functions.

int distance;

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

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

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