Looping in a function

I’m having difficulty trying to understand how to repeat a number of statements inside a funtion for a set length of time. After attempting a number of things I finally tried using “goto”. I understand it’s a no-no, but it makes sense to me for this application. However, I’m getting an error saying it wasn’t defined.
Help is greatly appreciated. Thanks.

The function is “pivotRight()”, here’s the code:

//This sketch controls a wheeled robot to avoid obstacles using
//an IR sensor as a range finder.

#include <Servo.h> //Get Servo library.

Servo myservo; //Declare servo name.

int sensorpin = 0; // analog pin used to connect the sharp sensor
int val = 0; //Variable to store IR value. 

//Set up pins for L298 motor board.
int dirPinAM1 = 2; 
int dirPinBM1 = 3;
int enMotor1 = 6; //Enable left motor.
int dirPinAM2 = 4;
int dirPinBM2 = 5;
int enMotor2 = 11; //Enable right motor.
unsigned long duraTion;
void setup()
{
  myservo.attach(9); //Output pin for servo.
  myservo.write(95);  //Set servo to front
Serial.begin(9600);
  // Declare output pins.
  pinMode(dirPinAM1, OUTPUT);
  pinMode(dirPinBM1, OUTPUT);
  pinMode(enMotor1, OUTPUT);
  pinMode(dirPinAM2, OUTPUT);
  pinMode(dirPinBM2, OUTPUT);
  pinMode(enMotor2, OUTPUT);
}

void loop(){
  myservo.write(95); //Set servo to front

  val = analogRead(sensorpin);  //Reads the value of the sharp sensor

  if(val < 200){ //Move forward if no object too close.
    forward();
  }
  if(val >= 200){
    pivotRight();
  }

}

void forward() //Move forward routine.
{
  digitalWrite(enMotor1, HIGH);
  digitalWrite(enMotor2, HIGH);
  delay(20);
  digitalWrite(dirPinAM1, HIGH);
  digitalWrite(dirPinBM1, LOW);
  digitalWrite(dirPinAM2, HIGH);
  digitalWrite(dirPinBM2, LOW);
  digitalWrite(enMotor1, LOW);
  digitalWrite(enMotor2, LOW);
  delay(50); 
}

void pivotRight() //Right turn routine.
{
  duraTion = millis();
  rTurn:
  digitalWrite(enMotor1, HIGH);
  digitalWrite(enMotor2, HIGH);
  delay(20);
  digitalWrite(dirPinAM1, HIGH);
  digitalWrite(dirPinBM1, LOW);
  digitalWrite(dirPinAM2,LOW);
  digitalWrite(dirPinBM2,HIGH);
  digitalWrite(enMotor1, LOW);
  digitalWrite(enMotor2, LOW);
  delay(50);
    if (millis() - duraTion <= 1000){
      goto rTurn;
  }
}

While gotos should be used sparingly, and the main problem is when they jump huge disstances which is not your case at all, this really looks like a do-while loop.

Thanks, that worked. I tried do-while before but must have had something wrong because it didn't do.

Can you post an example of your do-while code, so we can tell you why it isn't working?