8.5.09

i keep winning

It's rather strange. My ideas work. Here's my latest code, pulls in multiple weather feeds, in this case Leeds and London.


//woooooorks. weather in leeds & london

import simpleML.*;

XMLRequest leeds;
XMLRequest london;

int startTime; //create timer
int counter = 0;


void setup() {
size(200,200);
//create and start up request


leeds = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0078&u=c");
leeds.makeRequest();
london = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0085&u=c");
london.makeRequest();


startTime = millis();//more timer stuff
}

void draw() {
background(0);

//every 5 seconds, make new request
int now = millis();
if (now - startTime > 5000) {
leeds.makeRequest();
println("fio is epic");
}

if (now - startTime > 5001) {
london.makeRequest();
println("fio is awesome");
startTime = now;
}
}

//when request is complete
void netEvent(XMLRequest ml) {

String temp = ml.getElementAttributeText("yweather:condition", "temp");


String weather = ml.getElementAttributeText("yweather:condition","text");


if (weather.equals("Partly Cloudy")) {
println("Partly Cloudy");

}

if (weather.equals("Light Rain Shower")) {
println("Light Rain Shower");
}



}


Now all I need to do is populate the list with cities and different weather conditions.

No comments: