retrieving data

i am retrieving data from a site that forecasts auroral activity, the activity is in a form of 3 figures and is called ap.
the following code will retrieve a 3 figure number (ap), if u remove onButtonPressed and put in onLoad, and use
the following line:
trace(output["09MAR03"]); inside the code below
[code]
forecast = new XML();
forecast.load("http://www.pixelplay.org/jeff/phpr/f45.php");
forecast.onButtonPressed = function() {
     forecast = unescape(forecast);
     forecast = forecast.substring(forecast.indexOf("45-DAY AP FORECAST\n")+19, forecast.indexOf("45-DAY F10.7 CM FLUX FORECAST")-1);
     forecast = forecast.split("\n");
     output = new Array();
     for (j=0; j<forecast.length; j++) {
          forecast[j] = forecast[j].split(" ");
          for (i=0; i<forecast[j].length; i++) {
               output[forecast[j][i]] = forecast[j][i+1];
               i++;
          }
          delete forecast[j];
     }
     delete forecast;
     delete j;
     delete i;
}
[/code]
i am trying to retrieve the ap data, after the user specifies a date (up to 45 day) in the future.
i have buttons which will specify a date to grab
[code]
function ButtonPressed(buttonInstance) {
     if (buttonInstance == futSubmitBtn) {
         // get value of date combobox
          fmydate = futDateBox.getSelectedItem().data;
          trace("date: "+fmydate);
          // get value of month combobox
          fmonth = futMonthBox.getSelectedItem().data;
          trace("month: "+fmonth);
          // get value of year box
          fyear = futYearBox.getSelectedItem().data;
          trace("year: "+fyear);
     apValue = fmydate+fmonth+fyear;
     trace (apValue);
     trace(output[apValue]);
     }
}
[/code]
when i test it i get:
date: 09
month: MAR
year: 03
09MAR03
undefined
i just cant recieve an ap value back
pearcednAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

henrywwCommented:
hi pearcedn,

have u tried to trace the forecast.toString(); and see what get ...

trace(output[apValue])=undefined ...

so u are looping thru the nodes to produce a single dimension array is that what u are trying to do?
output[forecast[j][i]] = forecast[j][i+1];

.... let me try it later at home and see what i get ...

cheers :)
0
pearcednAuthor Commented:
if u use:
[code]
forecast = new XML();
forecast.load("http://www.pixelplay.org/jeff/phpr/f45.php");
forecast.onLoad = function() {
     forecast = unescape(forecast);
     forecast = forecast.substring(forecast.indexOf("45-DAY AP FORECAST\n")+19, forecast.indexOf("45-DAY F10.7 CM FLUX FORECAST")-1);
     forecast = forecast.split("\n");
     output = new Array();
     for (j=0; j<forecast.length; j++) {
          forecast[j] = forecast[j].split(" ");
          for (i=0; i<forecast[j].length; i++) {
               output[forecast[j][i]] = forecast[j][i+1];
               i++;
          }
          delete forecast[j];
     }
     delete forecast;
     delete j;
     delete i;
trace(output["09MAR03"]);
}
[/code]
as is, it will work fine, but i need the user to be able to change the date using yr,mnth and date buttons
0
henrywwCommented:
hmmm it works fine here, can u send me the fla

i have tried with ur code and nothing's wrong
this is what i do - hardcode

forecast = new XML();
forecast.load("http://www.pixelplay.org/jeff/phpr/f45.php");
forecast.onLoad = function (){
     trace("================ loaded ==================");
    forecast = unescape(forecast);
    forecast = forecast.substring(forecast.indexOf("45-DAY AP FORECAST\n")+19, forecast.indexOf("45-DAY F10.7 CM FLUX FORECAST")-1);
    forecast = forecast.split("\n");
     trace(forecast.join(",\n"));
     trace("================ end data ==================");
    output = new Array();
    for (j=0; j<forecast.length; j++) {
         forecast[j] = forecast[j].split(" ");
         for (i=0; i<forecast[j].length; i++) {
              output[forecast[j][i]] = forecast[j][i+1];
              i++;
         }
         delete forecast[j];
    }
    delete forecast;
    delete j;
    delete i;
     trace("the output here -> " + output["01APR03"]);
     ButtonPressed();
     
}

function ButtonPressed(buttonInstance) {
   // if (buttonInstance == futSubmitBtn) {
        // get value of date combobox
         fmydate = futDateBox.getSelectedItem().data;
           fmydate = "01";
         trace("date: "+fmydate);
         // get value of month combobox
         fmonth = futMonthBox.getSelectedItem().data;
           fmonth = "APR";
         trace("month: "+fmonth);
         // get value of year box
         fyear = futYearBox.getSelectedItem().data;
           fyear ="03";
         trace("year: "+fyear);
           
    apValue = fmydate+fmonth+fyear;
    trace (apValue);
    trace(output[apValue]);
   // }
}

// ===== and the trace output ====

date: 01
month: APR
year: 03
01APR03
015


strange ... u can trace the apValue but not the array ...
but i hardcoded these value and it gives me the correct result.
 
fmydate = "01";
fmonth = "APR";
fyear ="03";

which is 15

!!!!!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

pearcednAuthor Commented:
yes ive always been able to get it to work hard coding it, but i need it to work when the user inputs a date,mnth and yr:)
0
pearcednAuthor Commented:
by the way i have the conversion chart for geomagnetic to geographic but i dont think it will work, i fear i may have to go to a website that does conversions and put in every coordinate i have (6*(2*360)) then have my own array with these values in, what a pain in the a!%? that will be!
0
henrywwCommented:
ha ha ha ...

that aurora thing is really quite hard ...

and pearcedn if u can send me the fla so i know the setup of ur inputs then i can check easily...
0
pearcednAuthor Commented:
ok sending now, i will also send the mag file so you can seee what i mean
0
henrywwCommented:
got it ...

i will have an early night tonight ... quite tired today, & need to go back to work tomorrow, ... can make some time to have a look at that for u

good night :)
0
henrywwCommented:
i couldn't help ... had to look at the fla before i sleep then ....

i pasted the code ... from my comment to the fla and it works fine ...

the thing is, ... u have to wait for the data to finish loading before hitting the button and also make sure the date is > today within the next 45 days... nothing's wrong ... u have done everything, except maybe error checking if user enter a wrong date ... !!


cheers
0
pearcednAuthor Commented:
i dont understand, you had it hard coded!, can i see what youve done to it, i may understand better then, you know how thick i am!!!
0
henrywwCommented:
no no .. i removed the hardcode values ...
and use ur fla ... it works ...

ok i will send it back to u now ...
check the values in the output window, make sure u see the data before pressing the button... :)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pearcednAuthor Commented:
thats great thank, have 100:)
0
pearcednAuthor Commented:
i want to have your children
0
henrywwCommented:
??? huh .... ha ha ha ...
no no dave... 2 men can't have child

i have a dog ... u want it?

ha ha ha ...

btw, if u don't mind ... can i have the 500pts from ur very 1st question. i am having a race with rp,... lol .. we work on a few question together ... i got passed him not long ago and hold a higher rank for 3 days i think .. .then ... now he is up 2 rank ... ha ha ...

this is so much fun .. to be honest, i learn a lot from solving the questions ... and make some friends here too.

well ... really have to sleep now ...

cheers
0
henrywwCommented:
??? huh .... ha ha ha ...
no no dave... 2 men can't have child

i have a dog ... u want it?

ha ha ha ...

btw, if u don't mind ... can i have the 500pts from ur very 1st question. i am having a race with rp,... lol .. we work on a few question together ... i got passed him not long ago and hold a higher rank for 3 days i think .. .then ... now he is up 2 rank ... ha ha ...

this is so much fun .. to be honest, i learn a lot from solving the questions ... and make some friends here too.

well ... really have to sleep now ...

cheers
0
henrywwCommented:
no sorry ...

dave, i didn't mean a new one .. .we had an unclosed question ... here at
http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20512302.html

u can post a msg at the community section i think and have ur pts back for the new question u just posted ...

i am really sorry ...
i don't how u get so many question pts, but u are paying for it ... no ... please take it back and i will only claim it if i had done the work for it ...

cheers & thanks for your generosity :)
0
henrywwCommented:
u know i feel so bad for asking for the pts ... but ... even more if u have to pay to get the question pts ...

sorry mate...
0
pearcednAuthor Commented:
dont worry, you deserve them.....and more
0
henrywwCommented:
thanks ... and i really shouldn't :)

here is the link ... sample on how to withdraw question.
http://www.experts-exchange.com/Community_Support/Q_20504205.html

.... i have enough ... i really want to see how rp reacts when he see that next time the board updated... LOL ... so funny ...

actually i don't mind the pts, ... but it is kind of interesting to have someone to compete and work together to solve questions ...

thanks again dave ... Z Z Z ... must go now got to work on a sunday too ...

nite.
0
pearcednAuthor Commented:
its daz(darren), good luck against rp, hope i can help u beat him:)
sleep well
0
henrywwCommented:
sorry for that .. yeah darren...  daz ...

thanks again

:)
0
pearcednAuthor Commented:
did u have a look at that mag to geographic file, what do you reckon, doable?
0
henrywwCommented:
give me a bit more time .. .i will have a look at it soon ...

cheers :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.