INSTRUCTING ARDUINO TO RECALL A PREVIOUSLY GIVEN VALUE

Hello I have a dilemma which niggling away at me and I though I would appeal for your help. Shouldn't be too much sweat for all you cHipsters.

I'll briefly outline the issue as far as I understand it before pasting my code. I'm sending information from Processing to Arduino. On the Processing side there is a simple textbox into which I would like to enter some numbers defining distance (of a motor). On the arduino side I have set up a function to read this information. IN A SEPARATE FUNCTION I have asked arduino to move a motor the distance ascribed by the previous function. However, because I have not defined the distance "within this scope" i.e. within the SAME scope, it wont work. I would like to define the distance in one function and to store this information. i would like to be able to access this 'stored information' for use in other functions.

Here's the code:

void loop() {
   while (Serial.available()) {
      delay(10);
      char c = Serial.read();  
      readString += c;}
      if (readString.length() >0) {
      Serial.println(readString);
      int n;
      char carray[6];
      readString.toCharArray(carray, sizeof(carray));
      distance = atoi(carray);
   readString="";
   }
   if (incomingByte == 'Y') {
      Ystepper.move(distance); 
      Ystepper.runToPosition();
   }
}

As you can see, 'distance' is established as a local variable within the first function. As we know "Local variables are only visible to the function in which they are declared." How do I make it visible to the second function (obviously without simply making it a global variable, since the distance will need to be updated as the programs runs).

I hope this makes sense! XD I would greatly appreciate any comments and I hope this thread will be useful to others.

Arthur