Rerun Code V5 Autonomous Mode Recording

Hi,
So basically, I’m trying to write some code that would record all of the motor movement during driver control in 10 msec intervals, write it to a text file, that we could copy and paste into a new autonomous mode. However, whenever I run it, none of it works. No input from the controller makes it move, and none of the movements are recorded. Here is the attached code:

#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>


#include "vex.h"

using namespace vex;

// Brain should be defined by default
brain Brain;


// START V5 MACROS
#define waitUntil(condition)                                                   \
  do {                                                                         \
    wait(5, msec);                                                             \
  } while (!(condition))

#define repeat(iterations)                                                     \
  for (int iterator = 0; iterator < iterations; iterator++)
// END V5 MACROS


// Robot configuration code.
motor bleft = motor(PORT1, ratio18_1, false);

motor bright = motor(PORT2, ratio18_1, true);

motor fleft = motor(PORT3, ratio18_1, true);

motor fright = motor(PORT4, ratio18_1, false);

motor lift1 = motor(PORT7, ratio18_1, true);

motor lift2 = motor(PORT8, ratio18_1, false);

motor lift3 = motor(PORT19, ratio18_1, true);

motor lift4 = motor(PORT20, ratio18_1, false);

motor clawMotor = motor(PORT11, ratio18_1, false);

controller Controller1 = controller(primary);



// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
#pragma endregion VEXcode Generated Robot Configuration

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       {author}                                                  */
/*    Created:      {date}                                                    */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// Include the V5 Library
#include "vex.h"
#include "iostream"
#include "fstream"
#include "string"
  
// Allows for easier use of the VEX Library
using namespace vex;
using namespace std;

#define STRING(num) #num

int main() {
  while(true){

    clawMotor.setStopping(hold);
    Brain.Screen.clearScreen();
  // place driver control in this while loop

// Capping speed
    float sensitivity;
    sensitivity = 1.0;

    /*
    Controller1.Screen.clearLine(-1);
    Controller1.Screen.print("75%");
    */

    // Mobile goal controls
    if(Controller1.ButtonR1.pressing() == true){
        lift1.spin(reverse);
        lift2.spin(reverse);
    }
    else if(Controller1.ButtonR2.pressing() == true){
        lift1.spin(fwd);
        lift2.spin(fwd);
    }
    else {
        lift1.stop();
        lift2.stop();
    }

    if(Controller1.ButtonA.pressing() == true){
      clawMotor.spin(fwd);
    }
    else if(Controller1.ButtonB.pressing() == true){
      clawMotor.spin(reverse);
    }
    else {
      clawMotor.stop();
    }

  /* IF KEITH WANTS SENSITIVITY BACK
    if(Controller1.ButtonUp.pressing()){
        sensitivity = 0.75;
        
        Controller1.Screen.clearLine(-1);
        Controller1.Screen.print("75%");
        
    }
    else{}
    */
    
  /*
    if(Controller1.ButtonDown.pressing()){
        sensitivity = 0.5;
        
        Controller1.Screen.clearLine(-1);
        Controller1.Screen.print("50%");
        
    }
    else{}
  */

  // Conveyor belt controls (when needed)
    if(Controller1.ButtonL1.pressing()){
        lift3.spin(fwd, 100, pct);
        lift4.spin(fwd, 100, pct);
    }
    else if(Controller1.ButtonL2.pressing()){
        lift3.spin(reverse, 100, pct);
        lift4.spin(reverse, 100, pct);
    }
    else{
      lift3.stop();
      lift4.stop();
    }
    
    

    // Axis controls

    lift1.setStopping(hold);
    lift2.setStopping(hold);
    lift3.setStopping(hold);
    lift4.setStopping(hold);
    fleft.setStopping(brake);
    bleft.setStopping(brake);
    fright.setStopping(brake);
    bright.setStopping(brake);

    fleft.spin(directionType::rev, Controller1.Axis3.position(percent)*sensitivity, velocityUnits::pct);
    bleft.spin(directionType::rev, Controller1.Axis3.position(percent)*sensitivity, velocityUnits::pct);
    fright.spin(directionType::fwd, Controller1.Axis2.position(percent)*sensitivity, velocityUnits::pct);
    bright.spin(directionType::fwd, Controller1.Axis2.position(percent)*sensitivity, velocityUnits::pct);


    float bleftspeed;
    float brightspeed;
    float fleftspeed;
    float frightspeed;
    float lift1speed;
    float lift2speed;
    float lift3speed;
    float lift4speed;
    float clawspeed;

    string bleftdir;
    string brightdir;
    string fleftdir;
    string frightdir;
    string lift1dir;
    string lift2dir;
    string lift3dir;
    string lift4dir;
    string clawdir;

    string bleftscript;
    string brightscript;
    string fleftscript;
    string frightscript;
    string lift1script;
    string lift2script;
    string lift3script;
    string lift4script;
    string clawscript;
    string timing;

    ofstream f;
    
    bleftspeed = bleft.velocity(pct);
    brightspeed = bright.velocity(pct);
    fleftspeed = fleft.velocity(pct);
    frightspeed = fright.velocity(pct);
    lift1speed = lift1.velocity(pct);
    lift2speed = lift2.velocity(pct);
    lift3speed = lift3.velocity(pct);
    lift4speed = lift4.velocity(pct);
    clawspeed = clawMotor.velocity(pct);

  
    // Please don't make me fix this...this is really tedious code.
    if(bleft.rotation(deg) < 0){
      bleftdir = "reverse";
    }
    else if (bleft.rotation(deg) > 0){
      bleftdir = "fwd";
    }

    if(bright.rotation(deg) < 0){
      brightdir = "reverse";
    }
    else if(bright.rotation(deg) > 0){
      brightdir = "fwd";
    }
    
    if(fleft.rotation(deg) < 0){
      fleftdir = "reverse";
    }
    else if(fleft.rotation(deg) > 0){
      fleftdir = "fwd";
    }

    if(fright.rotation(deg) < 0){
      frightdir = "reverse";
    }
    else if(fright.rotation(deg) > 0){
      frightdir = "fwd";
    }

    if(lift1.rotation(deg) < 0){
      lift1dir = "reverse";
    }
    else if(lift1.rotation(deg) > 0){
      lift1dir = "fwd";
    }

    if(lift2.rotation(deg) < 0){
      lift2dir = "reverse";
    }
    else if(lift2.rotation(deg) > 0){
      lift2dir = "fwd";
    }

    if(lift3.rotation(deg) < 0){
      lift3dir = "reverse";
    }
    else if(lift2.rotation(deg) > 0){
      lift3dir = "fwd";
    }

    if(lift4.rotation(deg) < 0){
      lift4dir = "reverse";
    }
    else if(lift4.rotation(deg) > 0){
      lift4dir = "fwd";
    }

    if(clawMotor.rotation(deg) < 0){
      clawdir = "reverse";
    }
    else if(clawMotor.rotation(deg) > 0){
      clawdir = "fwd";
    }
  

    string bleft_str(STRING(bleftspeed));
    string bright_str(STRING(brightspeed));
    string fleft_str(STRING(fleftspeed));
    string fright_str(STRING(frightspeed));
    string lift1_str(STRING(lift1speed));
    string lift2_str(STRING(lift2speed));
    string lift3_str(STRING(lift3speed));
    string lift4_str(STRING(lift4speed));
    string claw_str(STRING(clawspeed));

    
    bleftscript = "bleft.spin(" + bleftdir + ", " + bleft_str + ");\n";
    brightscript = "bright.spin(" + brightdir + ", " + bright_str + ");\n";
    fleftscript = "fleft.spin(" + fleftdir + ", " + fleft_str + ");\n";
    frightscript = "fright.spin(" + frightdir + ", " + fright_str + ");\n";
    lift1script = "lift1.spin(" + lift1dir + ", " + lift1_str + ");\n";
    lift2script = "lift2.spin(" + lift2dir + ", " + lift2_str + ");\n";
    lift3script = "lift3.spin(" + lift3dir + ", " + lift3_str + ");\n";
    lift4script = "lift4.spin(" + lift4dir + ", " + lift4_str + ");\n";
    clawscript = "claw.spin(" + clawdir + ", " + claw_str + ");\n";
    f.open("reruncode.txt");
    f << "# Autonomous Code\n";
    f << bleftscript;
    f << brightscript;
    f << fleftscript;
    f << frightscript;
    f << lift1script;
    f << lift2script;
    f << lift3script;
    f << lift4script;
    f << clawscript;
    f << "wait(10, msec)";
    f.close();

    wait(10, msec);
    return 0;
    
    
  }
}

*Sorry about the awful formatting, “.v5cpp” files are not supported.

Is there a visible bug with my code or should I try a different approach? I would really appreciate some help!

Thanks!

edit: code tags added by moderators