//int MAX_IN_ARRAY = 1000; //PImage[] images = new PImage[MAX_IN_ARRAY]; ArrayList images = new ArrayList(); // will automatically be the right size ///int numberFound = 0; Don't need this anymore either void setup(){ size(600,600); String proxyURL = "http://itp.nyu.edu/icm/proxy/proxy.php?url="; //this is a relay station on itp that passes your request on, this allows your applet to work in a browser //I told you not to worry about this and just work in proccessing String myURL = "http://images.google.com/images?hl=en&q=dog"; //String[] arrayOfLines = loadStrings(myURL); String[] arrayOfLines = loadStrings(proxyURL + myURL); String oneLongString = join(arrayOfLines, ""); //the html comign back gets broken up in to lines but we want it in one long string, the join command does this String startingLandMark = "images?q=tbn:"; boolean stillHopeful = true; int startLookingAt = 0; while(true){ //different kind of repeat loop that goes for an undetermined number of interations //this always comes before the thing I want, notice I used the escape quote \" to include a quote in the quoted int start = oneLongString.indexOf(startingLandMark,startLookingAt); //you want to include the landmark so don't do this + startingLandMark.length(); //find the first occurance of this landmark and then march forward past the end of the landmark //also notice that I used a variation of indexOf that starts looking not at the beginning of the string //instead at a point I specify, in this case after what I already found if (start == -1) { //this means it never found anything in which case we should give up the ghost break; //stops the repeat loop; } int end = oneLongString.indexOf(" ",start + startingLandMark.length() ); //look for the first end landmark, in this case a space, after the starting landmark String imageURL = "http://images.google.com/" + oneLongString.substring(start,end); //add google's default path println("image" + imageURL); images.add(loadImage(proxyURL + imageURL)); //images[numberFound] = loadImage(proxyURL + imageURL); //numberFound++; //don't need to keep track anymore startLookingAt = end + 1; /*Don't have to worrry about this anymore if (numberFound >= MAX_IN_ARRAY ) { //don't overpack the array break; //stops the repeat loop; } */ } } void draw(){ //for(int i = 0; i < numberFound; i++){ for(int i = 0; i < images.size(); i++){ //size() keeps track of the number of images for you //image(images[i],i*30,0); PImage thisImage = (PImage) images.get(i); //this is what is harder about an array list //you have cast things as they come out of the list, in this case as a PImage, image(thisImage,i*30,0); } }