Having a problem using String Lists

edited December 2015 in Questions about Code

(Repost with hopefully correct code paste and the somewhat arcane method of indicating code...)

I'm attempting to use String Lists to create a simple scrolling text display. Below is a test snippet to show the prob I'm having with String Lists. The For Loop moves each line up, starting from the top and moving down. It appears there is a bug or problem with the String List 'get' function. If you break inside the for loop that does the scroll, you see in the variables that 'line' keeps getting a NULL value - and I suspect this is why the scroll doesn't really work.

Are there any known problems with the String lists, or am I just not using it correctly?

Code follows:

String curmsg[];  // Holds current message loaded from data folder
StringList vp;      // Will hold each line to be displayed on the view port
String line;

int i, j, k, vpWdoSize = 21;



void setup() {
  size(500, 440); // Width, Height; X-coord, Y-coord
  vp = new StringList();
  setvp();
  frameRate(5);

}

void draw() {
  background(0);
  for ( i=vpWdoSize-1; i<=0; i--) {
    vp.set(i, vp.get(i-1));  // EG: Line 19 moves to line 20; then line 18 moves to 19, etc...
    text(vp.get(i),30,50);
  }
  vp.set(0,k++ +" new data");
  text(frameCount+" dummy",30,random(30,420));

}

void setvp(){
  for (i=0; i<vpWdoSize; i++) {
    vp.set(i,"mt-"+i );  // initialize the viewport array

  }
  k = 0;

Answers

Sign In or Register to comment.