Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

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
0
pearcedn
Asked:
pearcedn
  • 13
  • 10
1 Solution
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 13
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now