Search code examples
javaarraysappendprocessing

Having Issues Appending to Array in Processing


I am trying to send an array over my serial port. The name of this array is 'send' and initially, it is empty. I want to append integers to this array but I am having issues doing so. I print the array, but it prints out nothing. Can someone help me out?

Thanks!

import processing.serial.*;

Serial myPort;
String val;

void setup(){
  size(200,200);
  String portName = Serial.list()[2];
  myPort = new Serial(this, portName, 9600);


}

void draw(){
    //myPort.write(0);
    //println(0);

}

int i = 0;
void mouseClicked(){
     //String myStr = "RGBY"; 
     String stre = "e|1";
     String strB = "B|1";
     String strG = "G|1";
     String strD = "D|1";
     String strA = "A|1";
     String strE = "E|1";

     println(stre);

     int[] send = {2};
     append(send, 1);
     printArray(send);
}

Solution

  • As per the reference, you should be saving the result of a function call:

    send = append(send, 1);