<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://www.fsdeveloper.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JB3DG</id>
	<title>FSDeveloper Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="http://www.fsdeveloper.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JB3DG"/>
	<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php/Special:Contributions/JB3DG"/>
	<updated>2026-05-14T23:49:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_XML_Variables_in_C_Gauges&amp;diff=10589</id>
		<title>C: XML Variables in C Gauges</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_XML_Variables_in_C_Gauges&amp;diff=10589"/>
		<updated>2018-07-23T17:36:29Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = true&lt;br /&gt;
| FS2002 = false&lt;br /&gt;
| XP10 = false &lt;br /&gt;
| XP9 = false &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==C: XML Variables in C Gauges==&lt;br /&gt;
&lt;br /&gt;
To control XML variables from a C gauge:&lt;br /&gt;
&lt;br /&gt;
 // declare the variable and pointer ID for the variable&lt;br /&gt;
 &lt;br /&gt;
 double pitot_cover = 1 ; // this is the C variable&lt;br /&gt;
 ID pitot_cover_id; // this is the pointer address to the XML variable&lt;br /&gt;
&lt;br /&gt;
 // Register the variable (this is the XML &amp;quot;name,&amp;quot; e.g., L:PitotCover&lt;br /&gt;
 &lt;br /&gt;
 case PANEL_SERVICE_PRE_INITIALIZE:&lt;br /&gt;
 pitot_cover_id = register_named_variable ( &amp;quot;PitotCover&amp;quot; );&lt;br /&gt;
 break;&lt;br /&gt;
&lt;br /&gt;
 // now, you can use the next two statements to &lt;br /&gt;
 // (a) associate the ID with the XML variable, then &lt;br /&gt;
 // (b) set the variable to be identical to the C variable, e.g., pitot_cover&lt;br /&gt;
 &lt;br /&gt;
 case PANEL_SERVICE_PRE_UPDATE:&lt;br /&gt;
 set_named_variable_value ( pitot_cover_id, (FLOAT64)pitot_cover ) ;&lt;br /&gt;
 break;&lt;br /&gt;
&lt;br /&gt;
 // now, in my mouse routine, I can set the value of pitot_cover, and it will &lt;br /&gt;
 //be automatically passed to the XML variable!&lt;br /&gt;
 &lt;br /&gt;
 BOOL FSAPI mouse_pitotcb( PPIXPOINT relative_point, FLAGS32 mouse_flags)&lt;br /&gt;
 {&lt;br /&gt;
   if ( pitot_cover == 0 ) { pitot_cover = 1 ; } else { pitot_cover = 0 ; }&lt;br /&gt;
   return FALSE;&lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
 // now, to use the XML variable to control the C variable, the only&lt;br /&gt;
 // difference is that you would use the get_named_variable_value command &lt;br /&gt;
 // instead, and omit the mouse code!&lt;br /&gt;
 &lt;br /&gt;
 pitot_cover = get_named_variable_value (pitot_cover_id); &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Alternate Method&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There is another method that may be used to communicate between C gauges and XML gauges, using the execute_calculator_code(); function. Here is the prototype for the function:&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Translating&amp;quot; the function into more easily understood pseudo-code, we have this:&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(XML variable name,units, floating point var name, integer variable name, string variable name);&lt;br /&gt;
&lt;br /&gt;
To use the function, first determine from the &amp;quot;units&amp;quot; of the XML variable whether the returned value will be a floating point number, an integer, or a string.&lt;br /&gt;
&lt;br /&gt;
When constructing the function call, only ONE of the fields 2 through 4 will be used, an the unused fields filled with &amp;quot;NULL&amp;quot; value. For example, we want to fetch an ADF frequency, so we&#039;d use something like this:&lt;br /&gt;
&lt;br /&gt;
 FLOAT64 adf1_frequency = 0; // first declare the float C variable&lt;br /&gt;
 execute_calculator_code(&amp;quot;(A:ADF ACTIVE FREQUENCY:1, KHz)&amp;quot;,&amp;amp;adf1_frequency,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
If the XML variable is an integer, here is an example:&lt;br /&gt;
&lt;br /&gt;
 SINT32 time_of_day; // first declare the integer C variable&lt;br /&gt;
 execute_calculator_code(&amp;quot;(E:TIME OF DAY,Enum)&amp;quot;,NULL,&amp;amp;time_of_day,NULL);&lt;br /&gt;
&lt;br /&gt;
If the XML variable is a string, here is an example:&lt;br /&gt;
&lt;br /&gt;
 PCSTRINGZ WP_NextID; // first declare the string C variable&lt;br /&gt;
 execute_calculator_code(&amp;quot;(A:GPS WP_NEXT ID,string)&amp;quot;,NULL,NULL,&amp;amp;WP_NextID);&lt;br /&gt;
&lt;br /&gt;
Custom L:variables may also be obtained following the same structure shown above.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;BOOLEAN:&#039;&#039;&lt;br /&gt;
 execute_calculator_code(&amp;quot;(L:MyCustomVariable,bool)&amp;quot;,NULL,&amp;amp;my_custom_variable,NULL);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;FLOAT:&#039;&#039;&lt;br /&gt;
 execute_calculator_code(&amp;quot;(L:MyCustomVariable,enum)&amp;quot;,&amp;amp;my_custom_variable,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
This method is much easier to use than the method described in the previous section. &lt;br /&gt;
&lt;br /&gt;
To SEND a command with this method, use the following format:&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(&amp;quot;(&amp;gt;K:SOUND_TOGGLE)&amp;quot;, NULL, NULL, NULL);&lt;br /&gt;
&lt;br /&gt;
If you need to pass a value for a SET type key_event, simply use the same syntax used in an XML gauge by prefixing the command with the value (which can itself be another XML variable as shown below):&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(&amp;quot;(A:Plane heading degrees gyro,degrees) (&amp;gt;K:HEADING_BUG_SET)&amp;quot;, NULL, NULL, NULL);&lt;br /&gt;
&lt;br /&gt;
To set an L:variable, use this syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Constant:&#039;&#039;&lt;br /&gt;
 execute_calculator_code(&amp;quot; 120 (&amp;gt;L:CustomXMLvar,enum)&amp;quot;,NULL,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;C Variable:&#039;&#039;&lt;br /&gt;
 FLOAT64 myVar = 100.00;&lt;br /&gt;
 char cTemp[60];&lt;br /&gt;
 sprintf_s(cTemp, %f%s, myVar, &amp;quot; (&amp;gt;L:MyVar,number)&amp;quot;);&lt;br /&gt;
 PCSTRINGZ szString = cTemp;&lt;br /&gt;
 execute_calculator_code(szString,NULL,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_XML_Variables_in_C_Gauges&amp;diff=10588</id>
		<title>C: XML Variables in C Gauges</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_XML_Variables_in_C_Gauges&amp;diff=10588"/>
		<updated>2018-07-23T17:35:54Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = true&lt;br /&gt;
| FS2002 = false&lt;br /&gt;
| XP10 = false &lt;br /&gt;
| XP9 = false &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==C: XML Variables in C Gauges==&lt;br /&gt;
&lt;br /&gt;
To control XML variables from a C gauge:&lt;br /&gt;
&lt;br /&gt;
 // declare the variable and pointer ID for the variable&lt;br /&gt;
 &lt;br /&gt;
 double pitot_cover = 1 ; // this is the C variable&lt;br /&gt;
 ID pitot_cover_id; // this is the pointer address to the XML variable&lt;br /&gt;
&lt;br /&gt;
 // Register the variable (this is the XML &amp;quot;name,&amp;quot; e.g., L:PitotCover&lt;br /&gt;
 &lt;br /&gt;
 case PANEL_SERVICE_PRE_INITIALIZE:&lt;br /&gt;
 pitot_cover_id = register_named_variable ( &amp;quot;PitotCover&amp;quot; );&lt;br /&gt;
 break;&lt;br /&gt;
&lt;br /&gt;
 // now, you can use the next two statements to &lt;br /&gt;
 // (a) associate the ID with the XML variable, then &lt;br /&gt;
 // (b) set the variable to be identical to the C variable, e.g., pitot_cover&lt;br /&gt;
 &lt;br /&gt;
 case PANEL_SERVICE_PRE_UPDATE:&lt;br /&gt;
 set_named_variable_value ( pitot_cover_id, (FLOAT64)pitot_cover ) ;&lt;br /&gt;
 break;&lt;br /&gt;
&lt;br /&gt;
 // now, in my mouse routine, I can set the value of pitot_cover, and it will &lt;br /&gt;
 //be automatically passed to the XML variable!&lt;br /&gt;
 &lt;br /&gt;
 BOOL FSAPI mouse_pitotcb( PPIXPOINT relative_point, FLAGS32 mouse_flags)&lt;br /&gt;
 {&lt;br /&gt;
   if ( pitot_cover == 0 ) { pitot_cover = 1 ; } else { pitot_cover = 0 ; }&lt;br /&gt;
   return FALSE;&lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
 // now, to use the XML variable to control the C variable, the only&lt;br /&gt;
 // difference is that you would use the get_named_variable_value command &lt;br /&gt;
 // instead, and omit the mouse code!&lt;br /&gt;
 &lt;br /&gt;
 pitot_cover_id = check_named_variable(&amp;quot;PitotCover&amp;quot;);&lt;br /&gt;
 pitot_cover = get_named_variable_value (pitot_cover_id); &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Alternate Method&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There is another method that may be used to communicate between C gauges and XML gauges, using the execute_calculator_code(); function. Here is the prototype for the function:&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Translating&amp;quot; the function into more easily understood pseudo-code, we have this:&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(XML variable name,units, floating point var name, integer variable name, string variable name);&lt;br /&gt;
&lt;br /&gt;
To use the function, first determine from the &amp;quot;units&amp;quot; of the XML variable whether the returned value will be a floating point number, an integer, or a string.&lt;br /&gt;
&lt;br /&gt;
When constructing the function call, only ONE of the fields 2 through 4 will be used, an the unused fields filled with &amp;quot;NULL&amp;quot; value. For example, we want to fetch an ADF frequency, so we&#039;d use something like this:&lt;br /&gt;
&lt;br /&gt;
 FLOAT64 adf1_frequency = 0; // first declare the float C variable&lt;br /&gt;
 execute_calculator_code(&amp;quot;(A:ADF ACTIVE FREQUENCY:1, KHz)&amp;quot;,&amp;amp;adf1_frequency,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
If the XML variable is an integer, here is an example:&lt;br /&gt;
&lt;br /&gt;
 SINT32 time_of_day; // first declare the integer C variable&lt;br /&gt;
 execute_calculator_code(&amp;quot;(E:TIME OF DAY,Enum)&amp;quot;,NULL,&amp;amp;time_of_day,NULL);&lt;br /&gt;
&lt;br /&gt;
If the XML variable is a string, here is an example:&lt;br /&gt;
&lt;br /&gt;
 PCSTRINGZ WP_NextID; // first declare the string C variable&lt;br /&gt;
 execute_calculator_code(&amp;quot;(A:GPS WP_NEXT ID,string)&amp;quot;,NULL,NULL,&amp;amp;WP_NextID);&lt;br /&gt;
&lt;br /&gt;
Custom L:variables may also be obtained following the same structure shown above.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;BOOLEAN:&#039;&#039;&lt;br /&gt;
 execute_calculator_code(&amp;quot;(L:MyCustomVariable,bool)&amp;quot;,NULL,&amp;amp;my_custom_variable,NULL);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;FLOAT:&#039;&#039;&lt;br /&gt;
 execute_calculator_code(&amp;quot;(L:MyCustomVariable,enum)&amp;quot;,&amp;amp;my_custom_variable,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
This method is much easier to use than the method described in the previous section. &lt;br /&gt;
&lt;br /&gt;
To SEND a command with this method, use the following format:&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(&amp;quot;(&amp;gt;K:SOUND_TOGGLE)&amp;quot;, NULL, NULL, NULL);&lt;br /&gt;
&lt;br /&gt;
If you need to pass a value for a SET type key_event, simply use the same syntax used in an XML gauge by prefixing the command with the value (which can itself be another XML variable as shown below):&lt;br /&gt;
&lt;br /&gt;
 execute_calculator_code(&amp;quot;(A:Plane heading degrees gyro,degrees) (&amp;gt;K:HEADING_BUG_SET)&amp;quot;, NULL, NULL, NULL);&lt;br /&gt;
&lt;br /&gt;
To set an L:variable, use this syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Constant:&#039;&#039;&lt;br /&gt;
 execute_calculator_code(&amp;quot; 120 (&amp;gt;L:CustomXMLvar,enum)&amp;quot;,NULL,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;C Variable:&#039;&#039;&lt;br /&gt;
 FLOAT64 myVar = 100.00;&lt;br /&gt;
 char cTemp[60];&lt;br /&gt;
 sprintf_s(cTemp, %f%s, myVar, &amp;quot; (&amp;gt;L:MyVar,number)&amp;quot;);&lt;br /&gt;
 PCSTRINGZ szString = cTemp;&lt;br /&gt;
 execute_calculator_code(szString,NULL,NULL,NULL);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_Decimal_to_BCO&amp;diff=10538</id>
		<title>C: Decimal to BCO</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_Decimal_to_BCO&amp;diff=10538"/>
		<updated>2018-02-12T14:33:56Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| FSXI = false&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = true&lt;br /&gt;
| FS2002 = true&lt;br /&gt;
| FS2000 = true&lt;br /&gt;
| FS98 = true&lt;br /&gt;
}}&lt;br /&gt;
== C: Decimal to BCO ==&lt;br /&gt;
&lt;br /&gt;
While the BCD conversion is useful for setting radios, it cannot be used for setting the Transponder. Instead, BCO must be used. Example below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 UINT32 Dec2Bco(int xpdr)&lt;br /&gt;
 {&lt;br /&gt;
 	int x = xpdr % 10;&lt;br /&gt;
 	int x1 = (((xpdr / 10) % 10) * 16) + x;&lt;br /&gt;
 	int x2 = (((xpdr / 100) % 10) * 256) + x1;&lt;br /&gt;
  	int x3 = ((xpdr / 1000) * 4096) + x2;&lt;br /&gt;
  	return UINT32(x3);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
To use:&lt;br /&gt;
&lt;br /&gt;
 trigger_key_event(KEY_XPNDR_SET, Dec2Bco(7700));//Emergency! Mayday! Mayday!&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_Decimal_to_BCO&amp;diff=10537</id>
		<title>C: Decimal to BCO</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_Decimal_to_BCO&amp;diff=10537"/>
		<updated>2018-02-12T14:32:09Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: Created page with &amp;quot;{{Infobox-Applicable-FSVersion | FSXI = false | FSXA = true | FSX = true | FS2004 = true | FS2002 = true | FS2000 = true | FS98 = true }} == C: Decimal to BCO ==  While the BC...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| FSXI = false&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = true&lt;br /&gt;
| FS2002 = true&lt;br /&gt;
| FS2000 = true&lt;br /&gt;
| FS98 = true&lt;br /&gt;
}}&lt;br /&gt;
== C: Decimal to BCO ==&lt;br /&gt;
&lt;br /&gt;
While the BCD conversion is useful for setting radios, it cannot be used for setting the Transponder. Instead, BCO must be used. Example below:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;math.h&amp;gt;&lt;br /&gt;
 UINT32 Dec2Bco(int xpdr)&lt;br /&gt;
 {&lt;br /&gt;
 	int x = xpdr % 10;&lt;br /&gt;
 	int x1 = (((xpdr / 10) % 10) * 16) + x;&lt;br /&gt;
 	int x2 = (((xpdr / 100) % 10) * 256) + x1;&lt;br /&gt;
  	int x3 = ((xpdr / 1000) * 4096) + x2;&lt;br /&gt;
  	return UINT32(x3);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
To use:&lt;br /&gt;
&lt;br /&gt;
 trigger_key_event(KEY_XPNDR_SET, Dec2Bco(7700));//Emergency! Mayday! Mayday!&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_C%2B%2B:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10517</id>
		<title>C: C++: Get Magnetic Variation for any lat/lon</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_C%2B%2B:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10517"/>
		<updated>2017-12-29T12:18:49Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: JB3DG moved page C: C++: Get Magnetic Variation for any lat/lon to C: Get Magnetic Variation for any lat/lon over redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[C: Get Magnetic Variation for any lat/lon]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10516</id>
		<title>C: Get Magnetic Variation for any lat/lon</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10516"/>
		<updated>2017-12-29T12:18:49Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: JB3DG moved page C: C++: Get Magnetic Variation for any lat/lon to C: Get Magnetic Variation for any lat/lon over redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| P3D4 = true&lt;br /&gt;
| P3D2 = true&lt;br /&gt;
| P3D = true&lt;br /&gt;
| FSXI = unknown&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = false&lt;br /&gt;
| FS2002 = false&lt;br /&gt;
| FS2000 = unknown&lt;br /&gt;
| FS98 = unknown&lt;br /&gt;
| XP10 = false &lt;br /&gt;
| XP9 = false &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following undocumented function may be used to avoid conflicts between navigation databases and scenery magnetic variation or for any other purpose the developer might find useful.&lt;br /&gt;
&lt;br /&gt;
In your choice of your project&#039;s header files, do the following function prototype:&lt;br /&gt;
&lt;br /&gt;
 typedef float(__stdcall *ffe_get_magvar64)(const _llaf64*);&lt;br /&gt;
&lt;br /&gt;
Then in your module_init function:&lt;br /&gt;
 &lt;br /&gt;
 #ifdef _M_X64&lt;br /&gt;
 #define PWORDX unsigned __int64&lt;br /&gt;
 #else&lt;br /&gt;
 #define PWORDX DWORD&lt;br /&gt;
 #end&lt;br /&gt;
 &lt;br /&gt;
 ffe_get_magvar64 fe_get_magvar64 = NULL;&lt;br /&gt;
 void FSAPI module_init(void)&lt;br /&gt;
 {&lt;br /&gt;
  HMODULE hfedll = NULL;&lt;br /&gt;
  GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, L&amp;quot;fe.dll&amp;quot;, &amp;amp;hfedll);&lt;br /&gt;
  if(hfedll )&lt;br /&gt;
   GetSimTime6 = (fGetSimTime)GetProcAddress(hfedll , MAKEINTRESOURCEA(4));  }&lt;br /&gt;
&lt;br /&gt;
Now wherever you wish to call this function, include the header where the prototype is contained and add:&lt;br /&gt;
&lt;br /&gt;
 extern ffe_get_magvar64 fe_get_magvar64;&lt;br /&gt;
&lt;br /&gt;
To call it and find out how much time has passed:&lt;br /&gt;
&lt;br /&gt;
 _llaf64 lla = {lat, lon, alt};//_llaf64 is a struct in the gauges.h. lat/lon are in degrees and alt is in meters. &lt;br /&gt;
 float mvar = fe_get_magvar64(&amp;amp;lla);&lt;br /&gt;
&lt;br /&gt;
NOTE:&lt;br /&gt;
&lt;br /&gt;
All FSX versions use ordinal 4. &lt;br /&gt;
For all 32bit versions of P3D however, use the following: &lt;br /&gt;
 fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, &amp;quot;?fe_get_magvar64@@YGMQAU_llaf64@@@Z&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
For all versions of P3D v4, use the following:&lt;br /&gt;
 fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, &amp;quot;?fe_get_magvar64@@YAMQEAU_llaf64@@@Z&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10514</id>
		<title>C: Get Magnetic Variation for any lat/lon</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10514"/>
		<updated>2017-12-29T12:15:19Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: JB3DG moved page C: Get Magnetic Variation for any lat/lon to C: C++: Get Magnetic Variation for any lat/lon&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| P3D4 = true&lt;br /&gt;
| P3D2 = true&lt;br /&gt;
| P3D = true&lt;br /&gt;
| FSXI = unknown&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = false&lt;br /&gt;
| FS2002 = false&lt;br /&gt;
| FS2000 = unknown&lt;br /&gt;
| FS98 = unknown&lt;br /&gt;
| XP10 = false &lt;br /&gt;
| XP9 = false &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following undocumented function may be used to avoid conflicts between navigation databases and scenery magnetic variation or for any other purpose the developer might find useful.&lt;br /&gt;
&lt;br /&gt;
In your choice of your project&#039;s header files, do the following function prototype:&lt;br /&gt;
&lt;br /&gt;
 typedef float(__stdcall *ffe_get_magvar64)(const _llaf64*);&lt;br /&gt;
&lt;br /&gt;
Then in your module_init function:&lt;br /&gt;
 &lt;br /&gt;
 #ifdef _M_X64&lt;br /&gt;
 #define PWORDX unsigned __int64&lt;br /&gt;
 #else&lt;br /&gt;
 #define PWORDX DWORD&lt;br /&gt;
 #end&lt;br /&gt;
 &lt;br /&gt;
 ffe_get_magvar64 fe_get_magvar64 = NULL;&lt;br /&gt;
 void FSAPI module_init(void)&lt;br /&gt;
 {&lt;br /&gt;
  HMODULE hfedll = NULL;&lt;br /&gt;
  GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, L&amp;quot;fe.dll&amp;quot;, &amp;amp;hfedll);&lt;br /&gt;
  if(hfedll )&lt;br /&gt;
   GetSimTime6 = (fGetSimTime)GetProcAddress(hfedll , MAKEINTRESOURCEA(4));  }&lt;br /&gt;
&lt;br /&gt;
Now wherever you wish to call this function, include the header where the prototype is contained and add:&lt;br /&gt;
&lt;br /&gt;
 extern ffe_get_magvar64 fe_get_magvar64;&lt;br /&gt;
&lt;br /&gt;
To call it and find out how much time has passed:&lt;br /&gt;
&lt;br /&gt;
 _llaf64 lla = {lat, lon, alt};//_llaf64 is a struct in the gauges.h. lat/lon are in degrees and alt is in meters. &lt;br /&gt;
 float mvar = fe_get_magvar64(&amp;amp;lla);&lt;br /&gt;
&lt;br /&gt;
NOTE:&lt;br /&gt;
&lt;br /&gt;
All FSX versions use ordinal 4. &lt;br /&gt;
For all 32bit versions of P3D however, use the following: &lt;br /&gt;
 fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, &amp;quot;?fe_get_magvar64@@YGMQAU_llaf64@@@Z&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
For all versions of P3D v4, use the following:&lt;br /&gt;
 fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, &amp;quot;?fe_get_magvar64@@YAMQEAU_llaf64@@@Z&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10513</id>
		<title>C: Get Magnetic Variation for any lat/lon</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_Get_Magnetic_Variation_for_any_lat/lon&amp;diff=10513"/>
		<updated>2017-12-29T12:14:14Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: Created page with &amp;quot;{{Infobox-Applicable-FSVersion | P3D4 = true | P3D2 = true | P3D = true | FSXI = unknown | FSXA = true | FSX = true | FS2004 = false | FS2002 = false | FS2000 = unknown | FS98...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| P3D4 = true&lt;br /&gt;
| P3D2 = true&lt;br /&gt;
| P3D = true&lt;br /&gt;
| FSXI = unknown&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = false&lt;br /&gt;
| FS2002 = false&lt;br /&gt;
| FS2000 = unknown&lt;br /&gt;
| FS98 = unknown&lt;br /&gt;
| XP10 = false &lt;br /&gt;
| XP9 = false &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The following undocumented function may be used to avoid conflicts between navigation databases and scenery magnetic variation or for any other purpose the developer might find useful.&lt;br /&gt;
&lt;br /&gt;
In your choice of your project&#039;s header files, do the following function prototype:&lt;br /&gt;
&lt;br /&gt;
 typedef float(__stdcall *ffe_get_magvar64)(const _llaf64*);&lt;br /&gt;
&lt;br /&gt;
Then in your module_init function:&lt;br /&gt;
 &lt;br /&gt;
 #ifdef _M_X64&lt;br /&gt;
 #define PWORDX unsigned __int64&lt;br /&gt;
 #else&lt;br /&gt;
 #define PWORDX DWORD&lt;br /&gt;
 #end&lt;br /&gt;
 &lt;br /&gt;
 ffe_get_magvar64 fe_get_magvar64 = NULL;&lt;br /&gt;
 void FSAPI module_init(void)&lt;br /&gt;
 {&lt;br /&gt;
  HMODULE hfedll = NULL;&lt;br /&gt;
  GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, L&amp;quot;fe.dll&amp;quot;, &amp;amp;hfedll);&lt;br /&gt;
  if(hfedll )&lt;br /&gt;
   GetSimTime6 = (fGetSimTime)GetProcAddress(hfedll , MAKEINTRESOURCEA(4));  }&lt;br /&gt;
&lt;br /&gt;
Now wherever you wish to call this function, include the header where the prototype is contained and add:&lt;br /&gt;
&lt;br /&gt;
 extern ffe_get_magvar64 fe_get_magvar64;&lt;br /&gt;
&lt;br /&gt;
To call it and find out how much time has passed:&lt;br /&gt;
&lt;br /&gt;
 _llaf64 lla = {lat, lon, alt};//_llaf64 is a struct in the gauges.h. lat/lon are in degrees and alt is in meters. &lt;br /&gt;
 float mvar = fe_get_magvar64(&amp;amp;lla);&lt;br /&gt;
&lt;br /&gt;
NOTE:&lt;br /&gt;
&lt;br /&gt;
All FSX versions use ordinal 4. &lt;br /&gt;
For all 32bit versions of P3D however, use the following: &lt;br /&gt;
 fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, &amp;quot;?fe_get_magvar64@@YGMQAU_llaf64@@@Z&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
For all versions of P3D v4, use the following:&lt;br /&gt;
 fe_get_magvar64 = (ffe_get_magvar64)GetProcAddress(hfedll, &amp;quot;?fe_get_magvar64@@YAMQEAU_llaf64@@@Z&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=C:_Decimal_to_BCD&amp;diff=10512</id>
		<title>C: Decimal to BCD</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=C:_Decimal_to_BCD&amp;diff=10512"/>
		<updated>2017-12-05T19:39:02Z</updated>

		<summary type="html">&lt;p&gt;JB3DG: /* C: BCD to Decimal and Decimal to BCD */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| FSXI = false&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = true&lt;br /&gt;
| FS2002 = true&lt;br /&gt;
| FS2000 = true&lt;br /&gt;
| FS98 = true&lt;br /&gt;
}}&lt;br /&gt;
== C: BCD to Decimal and Decimal to BCD ==&lt;br /&gt;
&lt;br /&gt;
This scheme was supplied by Arne Bartels which allows BCD conversion in both directions. Add the following to the master source file:-&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;math.h&amp;gt;&lt;br /&gt;
 #define Bcd2Dec(BcdNum) HornerScheme(BcdNum,0x10,10)&lt;br /&gt;
 #define Dec2Bcd(DecNum) HornerScheme(DecNum,10,0x10)&lt;br /&gt;
 &lt;br /&gt;
 UINT32 HornerScheme(UINT32 Num,UINT32 Divider,UINT32 Factor)&lt;br /&gt;
 {&lt;br /&gt;
    UINT32 Remainder=0,Quotient=0,Result=0;&lt;br /&gt;
    Remainder=Num%Divider;&lt;br /&gt;
    Quotient=Num/Divider;&lt;br /&gt;
    if(!(Quotient==0&amp;amp;&amp;amp;Remainder==0))&lt;br /&gt;
    Result+=HornerScheme(Quotient,Divider,Factor)*Factor+Remainder;&lt;br /&gt;
    return Result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Then for each sub-gauge that requires a BCD conversion use the following syntax:-&lt;br /&gt;
&lt;br /&gt;
 Bcd2Dec(bcd_number) for BCD to decimal and&lt;br /&gt;
 Dec2Bcd(dec_number) for decimal to BCD conversions.&lt;br /&gt;
&lt;br /&gt;
In order to send frequencies to the ADF radios, multiply the desired frequency by 10000:&lt;br /&gt;
&lt;br /&gt;
 float adf_freq = 0;&lt;br /&gt;
 adf_freq = 286.5;&lt;br /&gt;
 trigger_key_event(KEY_ADF_COMPLETE_SET, Dec2Bcd(adf_freq*10000));&lt;br /&gt;
&lt;br /&gt;
In order to send frequencies to the COM or NAV radios, multiply the desired frequency by 100:&lt;br /&gt;
&lt;br /&gt;
 float com_freq = 0;&lt;br /&gt;
 com_freq = 122.875;&lt;br /&gt;
 trigger_key_event(KEY_COM_RADIO_SET, Dec2Bcd(com_freq * 100));//Change the event ID as needed for the NAV radio or the particular COM radio you wish to set&lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>JB3DG</name></author>
	</entry>
</feed>