How to code a stepper to run a number of times

I am trying to code a stepper to turn back and forth 3 times then turn more afterwards.

Currently this script makes the motor turn back and forth once then more afterwards.

please help!

#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper1(1, 9, 8);

void setup()
{
stepper1.setMaxSpeed(600.0);
stepper1.setAcceleration(300.0);

int a=0;
}
void loop()
{
int a;

// runs with delay here oddly//
if (a<=3)

{
stepper1.runToNewPosition(-100);
stepper1.runToNewPosition(0);
a= a + 1;
}

else (a > 4);
{
stepper1.runToNewPosition(-800);
stepper1.runToNewPosition(0);
a= a + 1;
}

delay (1000);
}

Use the code button when posting your code so it doesn't contain smileys

and looks like this

I can't figure from your description what you want to happen that is not already happening.

If this line

 // runs with delay here oddly//

means that you are surprised that you can put the delay() function at that point rather than at the end of loop() you need to ask yourself why the time taken to complete loop() might be any different - it won't be.

...R

You have a local variable in setup() called "a" that's never used.

You have an uninitialized local variable in loop() that is used without being
initialized.

Perhaps you think they are the same variable - no, local variables are local to the
block they are declared in. Every time loop() runs it gets a new variable "a".

You need a global or static variable for your state.