help please: array filled in setup not visible in draw
in
Programming Questions
•
11 months ago
Advice needed please, I don't understand why I keep getting nullpointer exception in
void draw for this array called "numbers", the exception crops up in line 17, as soon as I reference
numbers.length. And
here's the data file that's loaded into
loadStrings, for testing.
thanks,
Scott
- String[] lines;
- float[] numbers;
- void setup() {
- size(1000,500);
- lines = loadStrings("conduct-small.txt");
- float[] numbers = new float[lines.length];
- for (int k = 0; k < lines.length; k++){
- String[] pieces = split(lines[k], ',');
- numbers[k] = float(pieces[5]);
- println(numbers[k]);
- }
- }
- void draw(){
- println(numbers.length);
- int test = int(random(numbers.length));
- float num = numbers[test] * -0.5; //roughly scaling the data so that it's relative to the middle of the sketch
- ellipse(width/2,height/2, num, num); // line from bottom of sketch up to "num" (scaled "pieces[5]") value
- }
1