Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

execute_calculator_code question

Featured Replies

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

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 
 

 

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

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

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

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

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

  • Moderator

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

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 
 

 

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

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.