Hi. I gave up on my electrostatic project and started a graph project. I need to receive an array to make a graph, but “ArrayIndexOutOfBoundsException: 1” keeps popping up.
Can anyone tell me a way of getting a number array input in processing, like using for or something?
Thank you.
P.S I’ll paste the code here for any kind person who will fix it or give me an alternative.
void setup(){
background(0);
size(1000, 1000);
textSize(30);
text("*GraphSaver Beta Instructions*\n\nPress the white button on the right top to end program.\n\n1.First enter the title.\n2.Then enter the number of rows.\n3.Then enter all of your data.\n4.A graph will be made.press enter to save and delete to erase it. \n\nWhen you finish reading click the screen.", 20, 30);
}
int num=0;
String title = "";
int data[]={0};
void draw(){
//text("*Instructions*\n\nPress the white button on the right top to end program.\n\n1.First enter the number of rows.\n2.Then enter the title.\n3.Then enter all of your data.\n4.A graph will be made.press enter to save and delete to erase it. ", 10, 10);
square(950, 0, 50);
textSize(30);
if(keynum==0)text(title, 100, 100);
if(keynum==1)text(num-48, 100, 100);
if(keynum==2 && imsi-1 == num)for(int i = 0; i <= imsi-1; i++)text(data[i], 100, 100);
}
void mousePressed(){//End process
background(0);
if(mouseX > 950 && mouseY < 50){
fill(200, 11, 22);
square(950, 0, 50);
delay(5000);
print("END");
}
}
void mouseMoved(){
if(mouseX > 950 && mouseY < 50){
fill(200, 11, 22);
square(950, 0, 50);
}
else {
fill(255);
square(950, 0, 50);
}
}
int imsi=0;//temp
int keynum=0;//how nany times key has been pressed-0:title, 1: number of rows, 2 : data
void keyPressed(){//input
background(0);
if(key == ENTER){keynum++;return;}
if(keynum == 0)title += key;
if(keynum == 1){
num = key;
}
if(keynum == 2){
data[imsi++]=key;
}
}