How to make indexers and motors work together (I am totally lost)

I working on a two-mortred robot that has two 6-volt motors attached to an H-bridge hooked up to my Arduino. I also have indexers on those motors the change state every half rotation of the motor before the transmission. I also have several other sensors hooked up to the other pins, which means that I decided to hook up both H-bridge enables to 5v and call it done. I only have two motors on the robot, so I am left to using tank steering. I was trying to make a function that only moves my motor half a before transmission rotation, however, it seems to be either stuck, or dependant on whether the other encoder is moving. It seems that the motors are acting properly, it is just my programming. Here are the relevant functions:

bool tempfight = false;
int i = 0;
bool j = right;
long k = sweep_tic_base;
long l = 0;

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
  pinMode(LEFTFOR, OUTPUT);
  pinMode(LEFTBACK, OUTPUT);
  pinMode(RIGHTFOR, OUTPUT);
  pinMode(RIGHTBACK, OUTPUT);
  pinMode(INDEXLEFTFOR, INPUT_PULLUP);
  digitalWrite(INDEXLEFTFOR, LOW);
  pinMode(INDEXRIGHTFOR, INPUT_PULLUP);
  digitalWrite(INDEXRIGHTFOR, LOW);
  pinMode(LED, OUTPUT);
  pinMode(PAUSEBUT, INPUT_PULLUP);
  digitalWrite(PAUSEBUT, LOW);
  nut(off);
  ledOn();
  delay(3000);
}

void loop () {
  
  dir = left;
  ledOn();
  forward(tick);
  Serial.print(tempfor);
  Serial.print("|---|");
  Serial.println(readin(INDEXLEFTFOR));
  ledOff();
  delay(3000);
}

And the functions that I’ve tucked away in a local library:

int readin(int tempc) {
  switch (tempc) {
    case BACKSONIC:
      tempreadin = BACK.distanceRead();
      return tempreadin;
    case FRONTSONIC:
      tempreadin = FRONT.distanceRead();
      return tempreadin;
      break;
    case IRFLEFT:
      return AnalogReadDigital(IRFLEFT, THRESH);
      break;
    case IRFRIGHT:
      return AnalogReadDigital(IRFRIGHT, THRESH);
      break;
    case IRLEFT:
      return AnalogReadDigital(IRLEFT, THRESH);
      break;
    case IRRIGHT:
      return AnalogReadDigital(IRRIGHT, THRESH);
      break;
    case PAUSEBUT:
      return digitalRead(PAUSEBUT);
      break;
    case INDEXLEFTFOR:
      return digitalRead(INDEXLEFTFOR);
      break;
    case INDEXLEFTBACK:
      return AnalogReadDigital(INDEXLEFTBACK, THRESH);
      break;
    case INDEXRIGHTFOR:
      return digitalRead(INDEXRIGHTFOR);
      break;
    case INDEXRIGHTBACK:
      return AnalogReadDigital(INDEXRIGHTBACK, THRESH);
      break;
  }
}

void forward(bool for_tick) {
  if (for_tick) {
    tempfor = readin(INDEXLEFTFOR);
    while (tempfor == readin(INDEXLEFTFOR)) {
      analogWrite(LEFTFOR, HIGH);
      analogWrite(LEFTBACK, LOW);
      analogWrite(RIGHTFOR, HIGH);
      analogWrite(RIGHTBACK, LOW);
    }
    nut(power);
  }
  else {
    digitalWrite(LEFTFOR, HIGH);
    digitalWrite(LEFTBACK, LOW);
    digitalWrite(RIGHTFOR, HIGH);
    digitalWrite(RIGHTBACK, LOW);
  }
}

Thanks, and, since I probably missed some functions, the whole package is included below.
Please tell me if I forgot something.

RedBot.Sumo.ino (1.43 KB)

Additional.h (5 KB)

You mean encoder, not indexer. An indexer is a kind of motor controller that does position control (using steppers or encoder).

Without all the code its impossible to figure stuff out.

Please post full details of the hardware, no real idea what kind of encoder you have and looking at the code
just creates more questions than answers from these snippets. analogReadDigital()??? What on earth does
that mean?