Archived

This topic is now archived and is closed to further replies.

Recommended Posts

I am trying to get the airport ICAO to show on my takeoff data card. I am able to get XML A:var etc via the execute_calculator_code but getting information via the fs9_gps is proving difficult. I know it is something I am doing wrong, but what ?The CodePCSTRINGZ icao;FLOAT64 FSAPI icao_string_cb (PELEMENT_STRING pelement ){ execute_calculator_code("(C:fs9gps:WaypointAirportICAO,string)",NULL,NULL,&icao); sprintf (pelement->string,"%04.0f", icao); return icao;}This then gives me one compile error: C2440: 'return' : cannot convert from 'PCSTRINGZ' to 'FLOAT64'Take the icao from return adding 0 and it compiles but as expected returns 0 in FS. I have tried different sprintf ie "%s", declaring the varibale as different types ie CHAR etc to no avail.:-zhelp

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

> sprintf (pelement->string,"%04.0f", icao);>> return icao;>}Your return should be either zero or false...Try:PCSTRINGZ icao;case PANEL_SERVICE_PRE_UPDATE:execute_calculator_code("(C:fs9gps:WaypointAirportICAO,string)",NULL,NULL,&icao);break;FLOAT64 FSAPI icao_string_cb( PELEMENT_STRING pelement){sprintf(pelement->string,"%s", icao );return 0;}Also, the return from the call to fs9gps may well be nothing if you haven't first told fs9gps where you're a/c is currently located. IOW, you need to send it your current lat/lon position... ;)

Share this post


Link to post
Share on other sites

Already tried the code you posted Bill, and get 0. Reading the rest of the post I can see why. I have not sent lat/lon position, which seems wierd as I am asking fs to tell me where I am, but I have to tell it first :-roll

Share this post


Link to post
Share on other sites

I am now sending lat and lon positions to the fs9gps.dllcase PANEL_SERVICE_PRE_UPDATE: lat_icao = "(A:Plane Latitude,degrees) (>C:fs9gps:WaypointAirportICAO,string)"; execute_calculator_code(lat_icao,NULL,NULL,NULL); lon_icao = "(A:Plane Longitude,degrees) (>C:fs9gps:WaypointAirportICAO,string)"; execute_calculator_code(lon_icao,NULL,NULL,NULL);then asking for it to show resultsexecute_calculator_code("(C:fs9gps:WaypointAirportICAO,string)",NULL,NULL,&airport_icao);break;then displaying the string in a callbackFLOAT64 FSAPI airport_icao_string_cb (PELEMENT_STRING pelement ){ sprintf (pelement->string,"%s", airport_icao); return 0;}and I get 0.I new I would have problems getting this to work :-(

Share this post


Link to post
Share on other sites

Ok, I'm uncertain what you're actually trying to accomplish... however...WaypointAiportICAO is for airport lookup.You can't send a latitude or a longitude to it. You would send an ICAO value to it and then you would be able to read the rest of the Airport Data variables.

Share this post


Link to post
Share on other sites

EdWhat I am trying to achive is, to be able to show which airport I am sitting at on my takeoff data card. So for example if I am sitting at Gatwick then my data card should display EGKK.How can I send an ICAO value to it when I could be sitting at any number of airports in FS, plus as far as I am aware there is no variable that I can send to the fs9gps.dll which would tell it what airport I am sitting at. As you have properly guessed I am even more confused *:-* Any chance of someone posting a bit of working code showing how to set and get variables from the gps ? I have done a search, and there are few who have had this problem, but unfortunately none of them have ever post a soluition :-(

Share this post


Link to post
Share on other sites

>>Any chance of someone posting a bit of working code showing>how to set and get variables from the gps ? I have done a>search, and there are few who have had this problem, but>unfortunately none of them have ever post a soluition :-(Seems it's not possible to retrieve fs9gps class values from a classic .gau/dll gauge, probably because of instantiation issues.I've been able to work with those vars only when called within a custom DLL preloaded through DLL.XML.Anyway, more tests would be necessary to clear all doubts.Tom

Share this post


Link to post
Share on other sites

>Ed>What I am trying to achive is, to be able to show which>airport I am sitting at on my takeoff data card. So for>example if I am sitting at Gatwick then my data card should>display EGKK.>>How can I send an ICAO value to it when I could be sitting at>any number of airports in FS, plus as far as I am aware there>is no variable that I can send to the fs9gps.dll which would>tell it what airport I am sitting at. As you have properly>guessed I am even more confused *:-* The problem is you're trying to send lat/lon to the wrong variable!See this for a complete list of GPS variables and uses:http://www.fsdeveloper.com/wiki/index.php?...:_How_to_AccessNote carefully that the lat/lon variables for WaypointAirportICAO are NOT SETTABLE... ;)You have the right idea (which I gave you previously) but are simply sending lat/lon incorrectly, and using the wrong "set" of variables. Use these instead for "Nearest Airport" (which of course is the one you're currently at!)NearestAirportCurrentICAONearestAirportCurrentLatitude NearestAirportCurrentLongitude Note that you can either Get or Set the above variables depending on what you need to accomplish! :)

Share this post


Link to post
Share on other sites

case PANEL_SERVICE_PRE_UPDATE: lat_icao = "(A:Plane Latitude,degrees)(>C:fs9gps:NearestAirportCurrentLatitude,degrees)"; execute_calculator_code(lat_icao,NULL,NULL,NULL); lon_icao = "(A:Plane Longitude,degrees)(>C:fs9gps:NearestAirportCurrentLongitude,degrees)"; execute_calculator_code(lon_icao,NULL,NULL,NULL);Now you want to retrieve NearestAirportCurrentICAO... execute_calculator_code("(C:fs9gps:NearestAirportCurrentICAO,string)",NULL,NULL,&airport_icao);break;

Share this post


Link to post
Share on other sites

Thanks for the reply Tom. Pitty you can not read the airport ICAO without a custom .dll. Will have to input it manually, like I do the active runway ;(Thanksedit:Just seen your post Bill, will give it a tryThanks

Share this post


Link to post
Share on other sites

>Thanks for the reply Tom. Pitty you can not read the airport>ICAO without a custom .dll. Will have to input it manually,>like I do the active runway ;(>>Thanks>>edit:>Just seen your post Bill, will give it a tryRefresh. I just updated to correct a boo-boo on my end wrt to 'string' versus 'degrees' in the script!Also, the link I gave to the Wiki article is from an original blog entry from Susan Ashlock. Although the list is "XML Centric" take cheer in knowing that anything available from the GPS.dll is also possible in C code as well......a bit more cumbersome to be sure, but certainly possible! :)

Share this post


Link to post
Share on other sites

Bill, did you ever try calling a gps value from a .gau/dll gauge?I mean, any kind of execute_calculator_code("(C:fs9gps:etc)",etc) ?I've read so many times this should work, but I couldn't suceed in retrieving even the most basic FlightPlanIsActiveFlightPlan...I must be doing something very wrong then. Would like to see a working example on this too!Tom

Share this post


Link to post
Share on other sites

I am sorry to say that I still get 0. I noticed the boo - boo with the string which should have been degrees, so changed that. I copied my gps.dll and put it in the main FS9 folder to see if that was the problem, but still got 0. I think there must be a problem with my computer, I am off to get a hammer :-)PCSTRINGZ lat_icao;PCSTRINGZ lon_icao;PCSTRINGZ airport_icao;FLOAT64 FSAPI airport_icao_string_cb (PELEMENT_STRING pelement ){ sprintf (pelement->string,"%s", airport_icao); return 0;}case PANEL_SERVICE_PRE_UPDATE: lat_icao = "(A:Plane Latitude,degrees) (>C:fs9gps:NearestAirportCurrentLatitude ,degrees)"; execute_calculator_code(lat_icao,NULL,NULL,NULL); lon_icao = "(A:Plane Longitude,degrees) (>C:fs9gps:NearestAirportCurrentLongitude,degrees)"; execute_calculator_code(lon_icao,NULL,NULL,NULL); execute_calculator_code("(C:fs9gps:NearestAirportCurrentICAO,string)",NULL,NULL,&airport_icao);break;Will test some more tomorrow.Thanks

Share this post


Link to post
Share on other sites

The GPS does not return results instantly.You'll have to repeatedly update the lat/lon inputs... and scan the value of NearestAirportItemsNumber until it shows there's a value.

Share this post


Link to post
Share on other sites