Array help
in
Programming Questions
•
1 year ago
Hi
i'm fairly new to processing, and i'm having some problem with a bunch of code. i'm working with strings, as you can see in the code, but it seems that i con't just add an item (string in this case) to the array by just giving it the next number in line...
What i mean is that i want to add a string to String strCmds[] by doing strCmds[strCmds.length] = "Hello"
- String recCmds[] = {"Sstringtest,,90,,250","SHello world,,10,,10"};
- String strCmds[] = {};
- PFont font;
- boolean printString = true;
- void setup() {
- size(500,500);
- font = createFont("Arial",14,false);
- textFont(font);
- }
- void draw() {
- //checkStr(recCmds);
- //drawStrings(strCmds);
- if (printString) {
- for(int i=0; i<recCmds.length; i++) {
- if(recCmds[i].substring(0,1) == "S") {
- strCmds[strCmds.length] = recCmds[i].substring(1);
- println(recCmds[i] + " , " + strCmds[strCmds.length-1]);
- println("OK");
- }
- }
- for(int i=0; i<strCmds.length; i++) {
- String[] comm = split(strCmds[i], ",,");
- if(comm.length == 3) {
- text(comm[0], float(comm[1]), float(comm[2]));
- }
- }
- printString = false;
- }
- }
Nick
1