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.

Question about modules in FS2002

Featured Replies

Hi all,I'm trying to create a module (dll file) that reads out the latitude, longitude and altitude of FS2002 (without using FSUIPC.dll).I use the following code to lookup the value of the latitude:MODULE_VAR latitude = {PLANE_LATITUDE};FLOAT64 FSAPI getlatitude( PMODULE_VAR val ){ lookup_var(&latitude); return latitude.var_value.n;}When I simply print getlatitude on the screen, I get the value 0x0040100F. I'm not a C++ expert, but this looks like a memory address to me. If I'm correct, I'm wondering if there's a way to read-out the value of the address and making the value of PLANE_LATITUDE visible.All comments and suggestions are welcome... :)Kind regards,http://home.planet.nl/~duijn181/cu2/koen.jpg

I'm also everything else than a C expert *lol*But try not to read the pointer direct. Example out of a Gauge manual:SINT16 nVsi = 0;MODULE_VAR curr_vsi = {VERTICAL_SPEED};lookup_var(&curr_vsi);nVsi = curr_vsi.var_value.n /////////////////////////////////////////////////////////////////////At your code:lookup_var(&latitude);latitude.var_value.n=new;return new;Regards,Harry

Hi Harry,Thanks for the reply. :)I've changed my code to:SINT16 nLatitude = 0;...lookup_var(&latitude);nLatitude = latitude.var_value.n;return nLatitude;but whatever I try, nLatitude always returns the value I've declared in the first line. E.g. when I change my first line to SINT16 nLatitude = 500;, nLatitude will always be 500...So it looks like there's something wrong with lookup_var(&latitude);...Kind regards,http://home.planet.nl/~duijn181/cu2/koen.jpg

read the .n value. It is a value of type double which is returned.#define LATSIF482DEG(x) ( ( ((double) (x)) / 40007000.0 * 360.0 ) )#define LONSIF482DEG2(x) ( ( ((double) (x)) / 35184372088832.0 * 45.0 ) )MODULE_VAR MMGPSLAT = {PLANE_LATITUDE}; FLOAT64 MGPSLAT;MODULE_VAR MMGPSLON = {PLANE_LONGITUDE}; FLOAT64 MGPSLON;initialize_var(&MMGPSLAT);initialize_var(&MMGPSLON);lookup_var(&MMGPSLAT);MGPSLAT = LATSIF482DEG(MMGPSLAT.var_value.n);lookup_var(&MMGPSLON);MGPSLON = LONSIF482DEG2(MMGPSLON.var_value.n);Best,

Hi,When I try initialize_var(&MMGPSLON);, as in the post above, I get the following error: "Unhandled exception: 0xC0000005: Access Violation.". I tried several things, but I'm not sure what's the exact cause of this error... If anyone knows, please tell me. :)Kind regards,http://home.planet.nl/~duijn181/cu2/koen.jpg

initialize_var() is not needed anymore. Just remove it from the code and everything should work fine.

Hi,When I remove initialize_var(), I still got the memory address back instead of the value... The code I'm using now (for the latitude) is:#define LATSIF482DEG(x) ( ( ((double) (x)) / 40007000.0 * 360.0 ) )MODULE_VAR MMGPSLAT = {PLANE_LATITUDE}; FLOAT64 MGPSLAT;FLOAT64 FSAPI getlatitude(){ lookup_var(&MMGPSLAT); MGPSLAT = LATSIF482DEG(MMGPSLAT.var_value.n); return MGPSLAT;}void main(){ cout:)Kind regards,http://home.planet.nl/~duijn181/cu2/koen.jpg

Is this code in a module (*.dll)? A dll that is in the modules subfolder of FS and is called by an external application, is loaded as a copy in the memory, so the lookup_var() in the copy loaded by FS is valid, the copy loaded by your application is not. Crashes are natural then.I tried a bit like that some time ago without much success. It is possible to link the both memories copies by using shared memory, but this still doesn't allow to share the address of lookup_var (or better the ImportTable).Arne Bartels

Hi Arne,I tried compiling it as a dll-file and placing it in the module subfolder of FS, but without success (FS crashes while loading).Is there a way to call lookup_var() in a dll file without crashing FS?Kind regards,http://home.planet.nl/~duijn181/cu2/koen.jpg

No way to call lookup_var directly from a FS module. The rasons are in my previous posts. There might be some routes to circumvate this, but it needs some good programming knowledge. - One possibility would be an asynchrounous lookup where "order" a lookup from the dll copy loaded from your application, that will be "answered" by a a loop started from the dll copy loaded by FS. - Or by using the windows messaging system, the "ordering" with the use of SendMessage (synchronous) or PostMessage (asynchrounous) from the dll loaded by your app and the answering by working with a message loop that reads for the same message id. AFAIK FSUIPC uses a system like this for answering read/write orders (in a much more elaborated way).Arne Bartels

Hi Arne,Thanks for the explanation.Looks like I have to stick to FSUIPC... :)Kind regards,http://home.planet.nl/~duijn181/cu2/koen.jpg

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.