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.

Passing strings between unrelated gauges

Featured Replies

  • Commercial Member

Okay... so I'm getting ready to be laughed at here :). I'm trying to pass string information between unrelated gauges, but I keep getting a big fat blank.//Client - first gaugeMODULE_VAR gnddata;char testdata[24]="Mary had a little lamb\0";PVOID pdata = gnddata.var_ptr;//---------------------------------------------------------------------------------------------------------void FSAPI info_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_PRE_INITIALIZE: initialize_var_by_name (&gnddata, "gnddata"); break; case PANEL_SERVICE_PRE_UPDATE: if(gnddata.var_ptr!=NULL)pdata=testdata; break: }}Now, I know at this point pdata points to 'Mary had a little lamb' becauseFLOAT64 FSAPI string1(PELEMENT_STRING pelement){ sprintf(pelement->string, "%s",pdata); return 0;}prints 'Mary had a little lamb'. It's at the other end of the business that it all falls down...//Server - second gaugechar gnddata[30]; //New shared variablechar *mary;char lamb[30];//---------------------------------------------------------------------------------------------------------void FSAPI debug_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_PRE_INSTALL: register_var_by_name (&gnddata, TYPE_PVOID, "gnddata"); break; case PANEL_SERVICE_PRE_UPDATE: mary=(char *)gnddata; strncpy(lamb,gnddata,sizeof(lamb)-1); break; case PANEL_SERVICE_PRE_KILL: unregister_var_by_name ("gnddata"); break; }}The following print statements all return a blank//---------------------------------------------------------------------------------------------------------FLOAT64 FSAPI string1(PELEMENT_STRING pelement){// sprintf(pelement->string, "%s",gnddata);// sprintf(pelement->string, "%s",mary); sprintf(pelement->string, "%s",lamb); return 0;}but being C, of course any one of them compiles correctly. WTH am I failing to do right?-Dai

I think It'll be easier in this case to think in terms of the server first then the client.I tried as best as i could to simplifty what you are doing. I didn't actually compile itbut I believe it will bring you closer to your goal.//---------------------------------------------------------------------------------------------------------//Server char server_gnddata[30] = "Mary had a little lamb\0"; ...void FSAPI debug_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_PRE_INSTALL: register_var_by_name (&server_gnddata, TYPE_PVOID, "gnddata"); break; case PANEL_SERVICE_PRE_KILL: unregister_var_by_name ("gnddata"); break; }}//-----------------------------------------------------------------//ClientMODULE_VAR client_gnddata;PVOID pdata; ...void FSAPI info_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_PRE_INITIALIZE: initialize_var_by_name (&client_gnddata, "gnddata"); break; case PANEL_SERVICE_PRE_UPDATE: if(client_gnddata.var_ptr!=NULL) { pdata= (PVOID)client_gnddata; } break: }}...FLOAT64 FSAPI string1(PELEMENT_STRING pelement){ sprintf(pelement->string, "%s",pdata); return 0;}//------------------------------------------------------Regards.Ernie.

ea_avsim_sig.jpg
  • Author
  • Commercial Member

Hi ErnieLong time no hear and apologies for the delayed reply! :( So it appears that I've been trying to do this entirely backwards.... I'm still finding one problem during compile time though:- if(client_gnddata.var_ptr!=NULL) { pdata=(PVOID)client_gnddata; }returns: error C2440: 'type cast' : cannot convert from 'MODULE_VAR' to 'PVOID' which I can partially understand as MODULE_VAR is a struct, but equally if(client_gnddata.var_ptr!=NULL) { pdata=(PVOID)client_gnddata.var_value.p; }compiles and prints '(null)'. Any ideas.....?-Dai

  • Author
  • Commercial Member

No luck.... I also tried [2] in case you were directing the variable at VAR_TYPE, then everything else in between just because I could. The reason I'm trying to do this is to try and create a 'drop-in' MFD-type gauge that is a pure dumb terminal and receives all its display information (strings and numeric data) from other gauges. In truth, it's more of an exercise than a necessity as it could all be done via a standard multigauge. What started this was the realisation that in the 'Sharing Variables' section of the sd2gau series I had always blithely talked about passing data between unrelated gauges and always used numbers as the illustration. Then I realised that I really didn't have much of a clue about passing strings in FS and I wanted to add that information into the next issue. So here I am.... but it's not a gamebreaker if I don't succeed and I'm very grateful for all the help I've received.-Dai

Hello Dai,Try this..if(client_gnddata.var_ptr!=NULL){ pdata= (PVOID)client_gnddata.var_ptr;}Regards.Ernie.

ea_avsim_sig.jpg
  • Author
  • Commercial Member

(Dai lowers head to desk very slowly in gratitude) Thank you Ernie :(- that's it. The one thing I didn't try after I'd changed the code on your first suggestion because I'd gotten so used to seeing _ptr print '(null)'. Of course it's always the one thing you didn't try that always works... :( :( Again, many thanks to those who tried to help. It'll be in the next issue of sd2gau.-Dai

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.