one of those null pointer exceptions
in
Programming Questions
•
1 year ago
A null pointer exception comes up only when I use the draw loop in code 2. But I am doing essentially the same thing I was doing in code 1. Why the difference? I assume it has to do with the draw loop??? But I traced it and cant find an issue...
- //No error message--it just runs through the loop.
- String flines[] = loadStrings("anotherTest.txt");
- for(int i=0; i<flines.length; i++) {
- println(flines[i]);
- }
- //This should be essentially the same this as above but I get a null pointer exception...
- String fLines[] = loadStrings("testzipcodes.txt");
- int folderCount = fLines.length;
- int i=0;
- void setup() {
- size(400,400);
- }
- void draw() {
- i++;
- println(fLines[i]);
- drawStatus(i);
- }
- /*Progress Bar
- Must have preloaded font and folderIndex and folderCount variables*/
- void drawStatus(int folderIndex) {
- float statusX = 30;
- float statusY = 60;
- float statusH= 20;
- float statusW = width - statusX*2;
- fill(5,5,5);
- if(folderIndex != folderCount) {
- text("Processing" + folderIndex + "out of" + folderCount + "...", statusX, statusY-10);
- }
- else {
- text("Finished processing folders", statusX, statusY-10);
- }
- fill(224, 217, 217);
- rect(statusX, statusY, statusW, statusH);
- fill(224, 57, 205);
- float completedW = map(folderIndex, 0, folderCount, 0, statusW);
- rect(statusX, statusY, completedW, statusH/5);
- }
1