Jump to content
Sign in to follow this  
Guest coal

execute_calculator_code question

Recommended Posts

Guest coal

Hello,After reading this: http://forums.flightsim.com/fswiki/index.p...les_in_C_Gauges, I decide to make some tests, and saw the easyness to access some FS variables.But in the mentioned link I read:"If the XML variable is a string, here is an example: PCSTRINGZ VorIcaoCode; // first declare the string C variableexecute_calculator_code("(C:fs9gps:WaypointICAO,string)",NULL,NULL,&VorIcaoCode);Take note that the string example also shows how we can easily fetch stuff from the GPS system using this technique!"Well, I can write strings using this method using sentences like (using GDI, not GDI+):PCSTRINGZ title;execute_calculator_code("(A:TITLE, string)", NULL, NULL, &title);TextOut(hdc, 10*dx, 40*dy, (LPCSTR)title, strlen(title));but if I try:PCSTRINGZ flp_title;execute_calculator_code("(C:fs9gps:FlightPlanTitle, string)", NULL, NULL, &flp_title);TextOut(hdc, 10*dx, 80*dy, (LPCSTR)flp_title, strlen(flp_title));or,SINT32 na_number;execute_calculator_code("(C:fs9gps:NearestAirportItemsNumber, number)", NULL, &na_number, NULL);sprintf(num_str_HSI, "%d", na_number);TextOut(hdc, 10*dx, 100*dy, num_str_HSI, strlen(num_str_HSI));The only thing I get is 0. or 0. Same thing happen if I use a GPS parameter:PCSTRINGZ gps_next;execute_calculator_code("(A:GPS WP_NEXT ID, string)", NULL, NULL, &gps_next);TextOut(hdc, 10*dx, 100*dy, (LPCSTR)gps_next, strlen(gps_next));Is there anything to do before access GPS variables using C:fs9gps:? Thanks for your help.Daniel

Share this post


Link to post
Share on other sites

Daniel, C:fs9gps:NearestAirportItemsNumber can be retrieved once ---Current AC position is entered(A:GPS POSITION LAT, Radians) (>@c:NearestAirportCurrentLatitude, Radians) (A:GPS POSITION LON, Radians) (>@c:NearestAirportCurrentLongitude, Radians)Max distance to search is inputted100 (>@c:NearestAirportMaximumDistance, NMiles)Max number of airports to find250 (>@c:NearestAirportMaximumItems)Now you can get (@c:NearestAirportItemsNumber), from that you can find the index then data about that airport(>@c:NearestAirportCurrentLine) (@c:NearestAirportCurrentICAO) (>@c:WaypointAirportICAO)INFO on COMM freq.1 (>@c:WaypointAirportCurrentFrequency) or diff number for diff comm (@c:WaypointAirportFrequencyValue,Mhz)Roman


20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

Share this post


Link to post
Share on other sites
Guest coal

Thanks Roman. I understand what you say, but why doesn't work something easier like:PCSTRINGZ flp_title;execute_calculator_code("(C:fs9gps:FlightPlanTitle, string)", NULL, NULL, &flp_title);TextOut(hdc, 10*dx, 80*dy, (LPCSTR)flp_title, strlen(flp_title));Daniel

Share this post


Link to post
Share on other sites

Hi,Do not use units when retrieving gps data with this function:execute_calculator_code("(C:fs9gps:FlightPlanTitle)", NULL, NULL, &flp_title);Gps.dll will directly return the default unit (string in this case).Tom

Share this post


Link to post
Share on other sites
Guest coal

Thanks Tom, for this reply and for your all contribution to FS forums you do.Unfortunately I cannot make that work.I put all that code in PANEL_SERVICE_PRE_DRAW.Is that the only thing to do?Nor can't retrieve any other gps data, numeric or string. Even using variables as in:PCSTRINGZ gps_next;execute_calculator_code("(A:GPS WP_NEXT ID, string)", NULL, NULL, &gps_next);Daniel

Share this post


Link to post
Share on other sites

Daniel, did you check whether gps.dll is present in main FS folder?I cannot think of other causes when you say other variables return correct values (?)Tom

Share this post


Link to post
Share on other sites
Guest coal

I'm testing with FS9 so gps.dll is in the modules folder. Anyway I copy it to main FS9 folder and nothing change.As I'm sure that the method works for other people I wonder what could be wrong.Thanks again.Daniel

Share this post


Link to post
Share on other sites

You should not be doing data lookup in the PRE_DRAW service.


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

Here is a working example. Note that the units ARE specified after the A:variable:case PANEL_SERVICE_PRE_UPDATE: execute_calculator_code("(A:ATC ID,string)",NULL,NULL,&n_number);break;Note also that the lookup is done in the PRE_UPDATE case.When trying to request data from the fs9gps.dll you need to first tell it where you are, 'cause it doesn't know!


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Bill, you're right there! the GPS.dll can run separate threads i believe.. If you try to recieve something that the GPS itself created IT MIGHT NOT WORK since the GPS disposed of the inputs already and created something else etc...Learned that one the hard way.. Do it yourself or not at all :-) RomanProud "TEAM AVSIM" RTW race member.


20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

Share this post


Link to post
Share on other sites
Guest coal

Thanks everybody for helping. I've been out and continued trying when back.I was sick trying to print a string, using for testing:PCSTRINGZ gps_next;execute_calculator_code("(A:GPS WP_NEXT ID, string)", NULL, NULL, &gps_next);TextOut(hdc, 10*dx, 100*dy, (LPCSTR)gps_next, strlen(gps_next));because in FS SDK they wrote GPS WP_NEXT ID and the right name of the variable is GPS WP NEXT ID (without the low dash).The above sentences work in PANEL_SERVICE_PRE_DRAW writing nothing in PANEL_SERVICE_PRE_UPDATE.Now the problem I have is that I cannot access GPS variables (strings or numbers) using execute_calculator_code, no mater if I try in PANEL_SERVICE_PRE_UPDATE or PANEL_SERVICE_PRE_DRAW.Could anyone of you give a complete working example for a GPS variable, let's say FlightPlanDepartureAirportIdent for example?This is what I tried in PANEL_SERVICE_PRE_DRAW (without success):PCSTRINGZ apt_ident;execute_calculator_code("(C:fs9gps:FlightPlanDepartureAirportIdent, string)", NULL, NULL, &apt_ident);TextOut(hdc, 10*dx, 100*dy, (LPCSTR)apt_ident, strlen(apt_ident));What should I lookup in the PRE_UPDATE case, if anything?Daniel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...