Loading...
Logo
Processing Forum

expand an Array[][]

in Programming Questions  •  1 month ago  
is there a way to expand an Array[][] ?  
I manage to expand the second array acces with append() but I didn't manage with the first. 

I also tried this, but it didn't work.
Copy code
  1. String[][]messOsc;
  2. int step;
  3. void setup() {
  4.   messOsc = new String[1][2] ;
  5.   step = 0 ;  

  6.   messOsc[step][0] = "addr";
  7.   messOsc[step][1] = "value";
  8.   step+=1;
  9.   messOsc = expand(messOsc, step+1);
  10.  
  11.    messOsc[step][0] = "addr2";
  12.   messOsc[step][1] = "value2";
  13. etc..
  14.    }
thank you. 

Replies(2)

Changing length of an Array is clumsy. Why not try this dynamic combo instead?
ArrayList<StringList>
Copy code
    final ArrayList<StringList> messOsc = new ArrayList();
    StringList osc;
    int step;
    
    void setup() {
      messOsc.add(new StringList());
      osc = messOsc.get(step);
    
      osc.append("addr");
      osc.append("value");
    
      println(messOsc);
    
      messOsc.add(new StringList());
      osc = messOsc.get(++step);
    
      osc.append("addr2");
      osc.append("value2");
    
      println(messOsc);
    
      exit();
    }
    
okay',
 thank you. 
your example is a List of a List, in fact ? 

I also saw a solution with StringDict, I'll test what's the more easier for me. 
thanks