Loading...
Logo
Processing Forum
OK so i was just trying to write a class that writes a bunch of different types of variables into one string,After a few gours research and construction i was getting near completion. Towards the end of the projsect i kep getting the "Syntax error maybe missing right parenthesis. Here is my code:


import processing.serial.*;

Serial myPort;

void Setup() {
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
  class Comm {
    string id;
    boolean e1;
    boolean e2;
    boolean e3;
    boolean e4;
    boolean e5;
    boolean e6;
    int XPn;
    double Xdist;
    int YPn;
    double Ydist;
    int ZPn;
    double Zdist;
  };



Comm(string tempid, boolean tempe1, boolean tempe2, boolean tempe3, boolean tempe4, boolean tempe5, boolean tempe6, int tempXPn, double tempXdist, int tempYPn, double tempYdist, int tempZPn, double tempZdist) {
    id = tempid;
    e1 = tempe1;
    e2 = tempe2;
    e3 = tempe3;
    e4 = tempe4;
    e5 = tempe5;
    e6 = tempe6;
    XPn = tempXPn;
    Xdist = tempXdist;
    YPn = tempYPn;
    Ydist = tempYdist;
    ZPn = tempZPn;
    Zdist = tempZdist;
  }


  void Assemble() {
    string d = ("{" + id + "}" + e1 + "," + e2 + "," + e3 + "," + e4 + "," + e5 + "," + e6 + ",");
    println d; // to test if it works
  }




  void Transmit() {
    myPort.write(d);
  }
  
}

Replies(3)

Your constructor (and the other methods) aren't contained within the class.
There are many syntax errors.

string should be written String
println d; should be println(d);
The class definition should enclose the constructor, and the methods you want to put in it.
It is better to define the class outside of the function.

You should start with a simple sketch, run it frequently to check the syntax, and progressively complete it.
Thanks for all the help.. maybe ill come back when i'm not such a novice.