Hi! Processing 2.0 freezes with this for loops. I don't know why!

edited November 2013 in Questions about Code

Here is my code with some comments. Please, help. Thanks.

StringList rawstring;
rawstring = new StringList();
String[] stopwords = loadStrings("stopwords2.txt");
String[] alphanumericals = loadStrings("alphanumericals.txt");
String rawcomp;
String stopcomp;

rawcomp=rawstring.get(450); // I load this individual lines to see if something 
println(rawcomp+ "\n"); // is wrong with the files.
stopcomp = stopwords[234]; //But it works to perfection.
println(stopcomp+ "\n");

rawcomp = rawcomp.replaceAll(stopcomp, ""); // I need to eliminate some stop words,
println(rawcomp + "\n"); //But I can't get through the next couple of For Loops. 
//Which is weird, because I used to be able, and I just changed the inside code.
//So I eliminated code that could be causing the problem until I ended with this:
for (int i = 0; i < rawstring.size(); i++) { 
  println("for 1, ciclo: " + i);
  rawcomp = rawstring.get(i);
  for (int j = 0; j<stopwords.length; j++) {
    println("for 2, ciclo: "+ i + " : " + j);
    stopcomp = stopwords[j];
// Processing freezes about the middle.

println(rawstring.size()); //<- It never gets here.


  • edited November 2013 Answer ✓

    I see no reason this would freeze Processing, but beware that writing too much to the console can indeed crash it, so perhaps it is your debugging that hides the real, original problem...

    Perhaps you can write the debug info to a file, instead, to avoid this problem.

    Note that we don't have your files, and we don't know how big they are, so it is hard to test or diagnose.

  • edited November 2013

    Thanks for the hint, Philho. I'm going to try it later today. :) As for the file size, I don't think they are too big. They are 450 Kb for alphanumericals.txt in 1480 lines, and 4 Kb for stopwords.txt in 567 lines.

  • edited November 2013 Answer ✓

    Just a sample from those files would be more than enough!
    And as mentioned above, too many print() calls in a short time halts Processing unfortunately! b-(

  • Yes! That was it. Thanks!

Sign In or Register to comment.