Call to parseInt() after readStringUntil().

I have a few functions to set/return data over Serial.

I got a problem where parseInt() doesn’t return expected values.

void alarm() {
  for (int i =1;i<6;){
  simc.print("AT+CALD=");simc.println(i);       // DELETE ALL ALARMS
  delay(100);
  simReply();
  i++;
  }

  simc.println("AT+CMGR=1");          //  show message record 1
  if (simc.find("ENG")) {             // typical text input -  ENG#5#45#-12#32000#180#3300#10
    TTL = simc.parseInt();
    Serial.println(TTL);
    TTH = simc.parseInt();
    Serial.println(TTH);
    TTC = simc.parseInt();
    Serial.println(TTC);             //   THIS FUNCTION WORKS FINE
    CDR = simc.parseInt();
    Serial.println(CDR);
    CYL = simc.parseInt();
    Serial.println(CYL);
    MCD = simc.parseInt();
    Serial.println(MCD);
    LBT = simc.parseInt();
    Serial.println(LBT);
    //EEPROM WRITE
    // param(9);
  }
  simc.println("AT+CMGR=1");   //tti     WAL1D20/05/05#16:00#  or   WAL3S16:00#2,3,4#
  if (simc.find("WAL")) {
    w = simc.parseInt();
    c = simc.read();
    D = (simc.readStringUntil('#'));         //   THIS FUNCTION WORKS FINE                 
    T = (simc.readStringUntil('#'));
    if (c == 'D') {
      alarmDate();
    }
    if (c == 'S') {
      alarmTime();
    }
  }
    simc.println("AT+CMGDA=\"DEL ALL\"");                    // delete all messages
  simReply();
     simc.println("AT+CALA?");                                    // question alarm setting
  simReply();
}
  void alarmDate() {
    Serial.println("alarmDate");
    simc.print("AT+CALA=\""); simc.print(D); simc.print(","); simc.print(T); simc.print(":00\","); simc.println(w);
    delay(1000);
    simReply();
    delay(1000);
    simc.println("AT+CMGR=1");
    if (simc.find("D")) {
      Serial.print("getting date");
      delay(1000);
      YY = simc.parseInt();                         //    UNTIL HERE - SEEMS THE parseInt SEEMS CORRUPTED?  
      Serial.println(YY);                           //    MAYBE DUE TO THE readStringUntil() CALL?
      Mm = simc.parseInt();
      Serial.println(Mm);
      DD = simc.parseInt();
      Serial.println(DD);
      alarmLoc();
    }
  }
  void alarmTime() {
    Serial.println("alarmTime");
    simc.print("AT+CALA=\""); simc.print(D); simc.print(":00\","); simc.print(w); simc.println(",");simc.println(T);
    delay(1000);
    simReply();
    delay(1000);
    simc.println("AT+CMGR=1");
    delay(1000);
    if (simc.find("S")) {
      alarmLoc();
    }
    alarmRep();
  }
  void alarmLoc() {
    Serial.println("getting time");
    if (w == 1) {
      BH1 = simc.parseInt();
      BM1 = simc.parseInt();
      delay(100);
      Serial.println(BH1);
      Serial.println(BM1);
    } if (w == 2) {
      EH1 = simc.parseInt();                //    AND THIS FUNCTION - DOES NOT RETURN INT's EXPECTED
      EM1 = simc.parseInt();
      delay(100);
      Serial.println(EH1);
      Serial.println(EM1);
    }
    if (w == 3) {
      BH2 = simc.parseInt();
      BM2 = simc.parseInt();
      delay(100);
      Serial.println(BH2);
      Serial.println(BM2);
    } if (w == 4) {
      EH2 = simc.parseInt();
      EM2 = simc.parseInt();
      delay(100);
      Serial.println(EH2);
      Serial.println(EM2);
    }
  }
  void alarmRep() {
    for (int i = 0; i < 6;) {
      R[i] = simc.parseInt();
      Serial.print("R:");Serial.println(R[i]);
      if (R[i] == 0) {
        break;
      }i++;
    }
    }

Maybe its down to the String call before parseInt?
Maybe its the ‘if’ statement and then expecting ‘char’ on subsequent serial calls?
**edited R to S

typical corrupted? output:

13:20:57.337 → getting date-2739
13:20:58.385 → 20
13:20:58.385 → 5
13:20:58.385 → getting time
13:20:58.478 → 6
13:20:58.478 → 13

SOLVED - but dont really know how!

I was calling parseInt() whilst within an 'if' statement which uses a Sting as an argument. So i think that parseInt() was actually parsing String type data.

Anyway i took the parseInt() calls and put them outside the if statement and this done the trick