VexIQ Text Error

I have this code, it is giving me errors at 10,10 or the #include “vex.h” (Just has a X and then(10, 10)B But this is automatically included, what should I do to fix this?

Thanks!

// 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 IQ MACROS
#define waitUntil(condition)                                                   \
 do {                                                                         \
   wait(5, msec);                                                             \
 } while (!(condition))
 
#define repeat(iterations)                                                     \
 for (int iterator = 0; iterator < iterations; iterator++)
// END IQ MACROS
 
 
// Robot configuration code.
controller Controller = controller();
motor Left = motor(PORT1, false);
motor Top = motor(PORT3, false);
motor Right = motor(PORT6, false);
motor Bottom = motor(PORT9, false);
 
// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
 
 
 
 
#pragma endregion VEXcode Generated Robot Configuration
 
//----------------------------------------------------------------------------
//                                                                           
//    Module:       main.cpp                                                 
//    Author:       <redacted>
//    Created:      4/26/22                                                 
//    Description:  Code For The X-Drive
//    Last Updated: 2/26/22                                     
//                                                                           
//----------------------------------------------------------------------------
 
// Include the IQ Library
#include "iq_cpp.h"
 
// Allows for easier use of the VEX Library
using namespace vex;
 
//Setting 1 Is include Display (worse performance) , Setting 0 is Do not include (Better performance)
void Int(Setting) {
if (setting == 1) {
  Top.setVelocity(0, percent)
 Right.setVelocity(0, percent)
 Left.setVelocity(0, percent)
 Bottom.setVelocity(0, percent)
  Top.setMaxTorque(100, percent)
 Right.setMaxTorque(100, percent)
 Left.setMaxTorque(100, percent)
 Bottom.setMaxTorque(100, percent)
  Top.setTimeout(1, seconds)
 Right.setTimeout(1, seconds)
 Left.setTimeout(1, seconds)
 Bottom.setTimeout(1, seconds)
 
 Top.spin(forward)
 Right.spin(forward)
 Left.spin(forward)
 Bottom.spin(forward)
  while (true) {
    Brain.Screen.setCursor(1, 1);
   Brain.Screen.print("Driving?  %s", Top.isDone() ? "Yes" : "No");
   Brain.Screen.print("%d", Brain.Battery.capacity(percent));
   wait(1, seconds)
   Brain.Screen.clearScreen()
  }
}
 
if (setting == 0) {
  Top.setVelocity(0, percent)
 Right.setVelocity(0, percent)
 Left.setVelocity(0, percent)
 Bottom.setVelocity(0, percent)
  Top.setMaxTorque(100, percent)
 Right.setMaxTorque(100, percent)
 Left.setMaxTorque(100, percent)
 Bottom.setMaxTorque(100, percent)
  Top.setTimeout(1, seconds)
 Right.setTimeout(1, seconds)
 Left.setTimeout(1, seconds)
 Bottom.setTimeout(1, seconds)
 
 Top.spin(forward)
 Right.spin(forward)
 Left.spin(forward)
 Bottom.spin(forward)
 
 }
}
 
void turnn() {
  while (Controller.AxisD.changed()) {
 Top.setVelocity(Controller.AxisD.position())
 Right.setVelocity(Controller.AxisD.position())
 Left.setVelocity(Controller.AxisD.position())
 Bottom.setVelocity(Controller.AxisD.position())
  }
 thread turnn = thread(turnn)
 
}
 
void movement() {
 while (true) {
 
 Top.setVelocity(Controller.AxisA.position()())
 Right.setVelocity(Controller.AxisA.position())
 Left.setVelocity(Controller.AxisA.position() * -1)
 Bottom.setVelocity(Controller.AxisA.position() * -1)
  if Controller.AxisD.changed() {
   thread turnn = thread(turnn)
   break;
 }
  }
}
 
int main() {
 
 thread Int = thread(Int(1))
 wait(1, seconds)
 thread movement = thread(movement)
 
}
 

What is the error? Did you add the other #includes above? Maybe try changing the "" for <>, like there are on the other ones?

I don’t know C++ much, but seems like a reasonable thing to try.

I tried that and it just gave me Brain not defined, sorry I just edited it, It does not give and error it just has an X. That is my whole code.

You have multiple errors in that code.
just a few

void Int(Setting) {

Setting needs a type (and probably not a good idea to name the function “Int”)

Top.setVelocity(0, percent)

missing semi-colon, there are many more.

while (Controller.AxisD.changed()) {

changed is used to register an event handler, it should not be called this way.

thread Int = thread(Int(1))

only pass the function name when creating a thread, you cannot pass a paramener this way.

3 Likes

Thanks,
Do you know why these did not show up? When I used to code in VS it would show all of them even if it had an error before. Is this something with Vex code?

edit - I hate Semicolons so much now

They should all show in the Errors tab, I put the code in VEXcode IQ 2.3.1 and many errors show up.

2 Likes

Weird, is it possible because of my schools internet that some of the Compiler server I have access to and not others?

Here, this will build, it will not actually work, you can figure that out.

code
//----------------------------------------------------------------------------
//                                                                           
//    Module:       main.cpp                                                 
//    Author:       Evan Wirzburger                                                 
//    Created:      4/26/22                                                 
//    Description:  Code For The X-Drive
//    Last Updated: 2/26/22                                     
//                                                                           
//----------------------------------------------------------------------------
 
// Include the IQ Library
#include "iq_cpp.h"
 
// Allows for easier use of the VEX Library
using namespace vex;
 
//Setting 1 Is include Display (worse performance) , Setting 0 is Do not include (Better performance)
void Initialize( int setting) {
  if (setting == 1) {
    Top.setVelocity(0, percent);
    Right.setVelocity(0, percent);
    Left.setVelocity(0, percent);
    Bottom.setVelocity(0, percent);
    Top.setMaxTorque(100, percent);
    Right.setMaxTorque(100, percent);
    Left.setMaxTorque(100, percent);
    Bottom.setMaxTorque(100, percent);
    Top.setTimeout(1, seconds);
    Right.setTimeout(1, seconds);
    Left.setTimeout(1, seconds);
    Bottom.setTimeout(1, seconds);
  
    Top.spin(forward);
    Right.spin(forward);
    Left.spin(forward);
    Bottom.spin(forward);
    
    while (true) {
      Brain.Screen.setCursor(1, 1);
      Brain.Screen.print("Driving?  %s", Top.isDone() ? "Yes" : "No");
      Brain.Screen.print("%d", Brain.Battery.capacity(percent));
      wait(1, seconds);
      Brain.Screen.clearScreen();
    }
  }
 
  if (setting == 0) {
    Top.setVelocity(0, percent);
    Right.setVelocity(0, percent);
    Left.setVelocity(0, percent);
    Bottom.setVelocity(0, percent);
    Top.setMaxTorque(100, percent);
    Right.setMaxTorque(100, percent);
    Left.setMaxTorque(100, percent);
    Bottom.setMaxTorque(100, percent);
    Top.setTimeout(1, seconds);
    Right.setTimeout(1, seconds);
    Left.setTimeout(1, seconds);
    Bottom.setTimeout(1, seconds);
  
    Top.spin(forward);
    Right.spin(forward);
    Left.spin(forward);
    Bottom.spin(forward);
  }
}
 
void turnn() {
  Top.setVelocity(Controller.AxisD.position(), percent);
  Right.setVelocity(Controller.AxisD.position(), percent);
  Left.setVelocity(Controller.AxisD.position(), percent);
  Bottom.setVelocity(Controller.AxisD.position(), percent);
}
 
void movement() {
 while (true) {
  Top.setVelocity(Controller.AxisA.position(), percent);
  Right.setVelocity(Controller.AxisA.position(), percent);
  Left.setVelocity(Controller.AxisA.position() * -1, percent);
  Bottom.setVelocity(Controller.AxisA.position() * -1, percent);
  }
}
 
int main() {
 
 Initialize(1);
 wait(1, seconds);

 movement();
 
}
2 Likes

Thank you. Can you lock? (idk if it is appropriate but I don’t want to clutter)

1 Like