If statement for serial display project

One part of my project consist of looking at a buffer location and printing that number "1 2 3 or 4" (actual number in buffer) to a serial display which is working great. Now I am trying to incorporate my animation which scrolls the numbers left if going from "4 to 3, 3 to 2, 2 to 1" or scrolling right if going from "1 to 2, 2 to 3, 3 to 4" I am having trouble finding how I would write an "if" statement to do this.
The simple code below writes the gear to the display. When a gear is shifted an "a" or "G" will flash into the buffer between gears changes so I've stated to only serial.write the 1, 2, 3, or4. I'm not quite sure if the "a" or "G" will cause an issue in the If statement for the animation:

    Serial1.write (MOVETO);
    Serial1.write (END);
if ((buffer [ GEAR_POSITION ] == '1') ||
    (buffer [ GEAR_POSITION ] == '2') ||
    (buffer [ GEAR_POSITION ] == '3') ||
    (buffer [ GEAR_POSITION ] == '4'))
    {
    Serial1.write(buffer[ GEAR_POSITION ]);

}
If it help to see the animation it is shown here - YouTube

I appreciate any help on this.

You really need to post your entire code. Whatyou show us is not nearly enough to determine what you need to do.

That being said, here's a general idea.

Start with the current gear position in a variable called something like currentGear
When you change to another gear, place the new value into a variable called something like newGear
Then check for what direction it shifted.
If newGear still equals currentGear, do nothing.

  if ( currentGear < newGear ) {
    // scroll right
  }
  if ( currentGear > newGear ) {
    // scroll left
  }
  currentGear = newGear;