?
Solved

retrieving data

Posted on 2003-03-06
23
Medium Priority
?
179 Views
Last Modified: 2010-04-03
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
Comment
Question by:pearcedn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 10
23 Comments
 
LVL 6

Expert Comment

by:henryww
ID: 8080729
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
 

Author Comment

by:pearcedn
ID: 8081827
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
 
LVL 6

Expert Comment

by:henryww
ID: 8090769
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:pearcedn
ID: 8093519
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
 

Author Comment

by:pearcedn
ID: 8094389
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
 
LVL 6

Expert Comment

by:henryww
ID: 8094596
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
 

Author Comment

by:pearcedn
ID: 8094767
ok sending now, i will also send the mag file so you can seee what i mean
0
 
LVL 6

Expert Comment

by:henryww
ID: 8095029
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
 
LVL 6

Expert Comment

by:henryww
ID: 8095084
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
 

Author Comment

by:pearcedn
ID: 8095097
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
 
LVL 6

Accepted Solution

by:
henryww earned 400 total points
ID: 8095102
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
 

Author Comment

by:pearcedn
ID: 8095132
thats great thank, have 100:)
0
 

Author Comment

by:pearcedn
ID: 8095134
i want to have your children
0
 
LVL 6

Expert Comment

by:henryww
ID: 8095170
??? 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
 
LVL 6

Expert Comment

by:henryww
ID: 8095171
??? 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
 
LVL 6

Expert Comment

by:henryww
ID: 8095203
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
 
LVL 6

Expert Comment

by:henryww
ID: 8095214
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
 

Author Comment

by:pearcedn
ID: 8095217
dont worry, you deserve them.....and more
0
 
LVL 6

Expert Comment

by:henryww
ID: 8095229
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
 

Author Comment

by:pearcedn
ID: 8095244
its daz(darren), good luck against rp, hope i can help u beat him:)
sleep well
0
 
LVL 6

Expert Comment

by:henryww
ID: 8097043
sorry for that .. yeah darren...  daz ...

thanks again

:)
0
 

Author Comment

by:pearcedn
ID: 8097621
did u have a look at that mag to geographic file, what do you reckon, doable?
0
 
LVL 6

Expert Comment

by:henryww
ID: 8098045
give me a bit more time .. .i will have a look at it soon ...

cheers :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question