Programming a "Reset" button

Good afternoon, I'm having a bit of trouble with my most recent project.. I've posted once before, and i got a lot of help, although realizing later that it wasn't what i exactly needed, as the demands changed after.. Thing is, this time, I need a external reset button for my Arduino Mega ADK, and I know, it's a no brainer, connect a cable from the reset pin to a momentary switch, and the other side of the switch will be connected to the GND pin..

My issue is, my robotic arm doesn't have a claw, it uses a electromagnet.. And when i press reset, the electromagnet will also be disabled, and it shouldn't, because if I press the reset button "mid-work" the piece it carries will fall down..

By the way, I'm not using a regular stop button, because if I used "if's", the stop button will not stop the program "mid-function", only after it's done the function..

I also tried "interrupts" but delays won't work, and I know there is a way around it, but right now i don't have that much time to learn it..

I think I've explained it good enough.. I'll post my code below:

Thanks in advance!!

int const buttonPin  = 21; //botão STOP

int const p1 = 40; // botão 1 ENTRADAS
int const p2 = 41; // botão 2
int const p3 = 42; // botão 3
int const p4 = 43; // botão 4
int const rodaresquerda = 44;
int const rodardireita = 45;
int const braco1frente = 46;
int const braco1tras = 47;
int const eletroimanon = 48;
int const eletroimanoff = 49;
int const antebracofrente = 50;
int const antebracotras = 51;
int const supelecfrente = 52;
int const supelectras = 53;

int const servo = 34; // SAIDAS
int const rotativomais = 33;
int const rotativomenos = 32;
int const bracomais = 31;
int const bracomenos = 30;
int const antebracomais = 29;
int const antebracomenos = 28;
int const suportegarramais = 27;
int const suportegarramenos = 26;
int const electro = 25;

int servotmp; //variáveis
int rotativomaistmp;
int rotativomenostmp;
int bracomaistmp;
int bracomenostmp;
int antebracomaistmp;
int antebracomenostmp;
int suportegarramaistmp;
int suportegarramenostmp;
int electrotmp;

bool servoFlag; //BANDEIROLAS
bool rotativomaisFlag;
bool rotativomenosFlag;
bool bracomaisFlag;
bool bracomenosFlag;
bool antebracomaisFlag;
bool antebracomenosFlag;
bool suportegarramaisFlag;
bool suportegarramenosFlag;
bool electroFlag;


void setup() {
  pinMode (40, INPUT);
  pinMode (41, INPUT);
  pinMode (42, INPUT);
  pinMode (43, INPUT);
  pinMode (44, INPUT);
  pinMode (45, INPUT);
  pinMode (46, INPUT);
  pinMode (47, INPUT);
  pinMode (48, INPUT);
  pinMode (49, INPUT);
  pinMode (50, INPUT);
  pinMode (51, INPUT);
  pinMode (52, INPUT);
  pinMode (53, INPUT);


  pinMode (34, OUTPUT);
  pinMode (33, OUTPUT);
  pinMode (32, OUTPUT);
  pinMode (31, OUTPUT);
  pinMode (30, OUTPUT);
  pinMode (29, OUTPUT);
  pinMode (28, OUTPUT);
  pinMode (27, OUTPUT);
  pinMode (26, OUTPUT);
  pinMode (25, OUTPUT);

}
void loop() {
  if (digitalRead(eletroimanon) == HIGH) { //botão start está feito
  primeiropasso:
    if (digitalRead(reset) == HIGH){
    digitalWrite(suportegarramais, HIGH);
    delay (2000);
    else 
  
 
segundopasso:
    digitalWrite(suportegarramais, LOW);
    delay(2000);

terceiropasso:
    digitalWrite(suportegarramenos, HIGH);
    delay(2000);
    

quartopasso:
    digitalWrite(suportegarramenos, LOW);
    delay(2000);
  }
}

By the way, I'm not using a regular stop button, because if I used "if's", the stop button will not stop the program "mid-function", only after it's done the function..

"After it's done the function" should be a matter of nanoseconds. That is plenty often for reading the switch state. Clearly, your code is riddled with delay()s. You MUST get rid of them.

but right now i don't have that much time to learn it..

Well, you better find the time. Otherwise, a failing grade is in your future.

  pinMode (34, OUTPUT);
  pinMode (33, OUTPUT);
  pinMode (32, OUTPUT);
  pinMode (31, OUTPUT);
  pinMode (30, OUTPUT);
  pinMode (29, OUTPUT);
  pinMode (28, OUTPUT);
  pinMode (27, OUTPUT);
  pinMode (26, OUTPUT);
  pinMode (25, OUTPUT);

Did you forget that you gave these pins names?

  primeiropasso:

WTF?

If you put a pull-up or pull-down resistor on the output pin that controls the magnet you can make it default to "Magnet On" when the reset button changes all the pins to inputs. Then make sure you use digitalWrite() to turn on the magnet before you change the pin to an output. Then you have to figure out if you have a load attached and, if so, what to do with it.