We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I have been working on a project to get all the upcoming shows playing at the Boch Center in Boston, MA. The show listings can be found at the following url http://www.bochcenter.org/buy/show-listing. I have been watching the working with data tutorial videos on YouTube by Daniel Shiffman, which I would highly recommend to anyone who has questions about this subject. Below is the code I have written for my project.
String[] rawhtml;
String [] shows;
String html;
int j = 0;
void setup(){
rawhtml = loadStrings("http://www.bochcenter.org/buy/show-listing");
shows = new String[75];
}
void draw(){
for(int i = 0; i < rawhtml.length; i++){
if(rawhtml[i].indexOf("<div class=\"show-title\">") >= 0){
shows[j] = rawhtml[i+3];
j++;
}
}
printArray(shows);
}
It almost works, when printArray(shows) starts printing results in the bottom of the screen I do see the show listing information I am looking for. My problem is I get an "ArrayIndexOutOfBoundsException: 75" error. I feel like I just need an else statement to stop my int j from going over the boundary but I'm not sure what that statement should be. Does anyone know how to keep my int j from going out of bounds?
Thank you for the help.
Answers
Several things
There is a new forum and you want to go there
After line 11 say j=0
Line 14: i+3 goes beyond last index
Line 11: replace 75 with rawhtml.length
Thanks for the help Chrisir. I still don't quite understand the code logic you suggested. I will take this discussion over to the new forum and ask over there.
Thanks a lot mate.
Each of the 3 points would require a small explanation ;-)