n4gix
Resource contributor
- Messages
- 11,674
- Country

I'm glad that there are so many ways to write scripts, because some methods just don't seem to work out too well for me.
In any case, the King Air 350i has a pushbutton near the center of the main panel that will tune COM1 Active to the emergency frequency of 121.50 MHz with a single push. Pressing the button again will revert to the previously tuned frequency.
For the VC, I wrote this bit of script that controls the illuminated button, and sends a flag to my logic gauge to handle the hard stuff:
In the logic gauge, both the control variable and the button's flag variable are monitored. Once the appropriate action is taken, the flag variable is reset so the evaluation will stop.
The @Macro though is where nothing seems to work except the old-fashioned, tried and true Horner Scheme:
Ah well, at least it does work 100% of the time! 
In any case, the King Air 350i has a pushbutton near the center of the main panel that will tune COM1 Active to the emergency frequency of 121.50 MHz with a single push. Pressing the button again will revert to the previously tuned frequency.
For the VC, I wrote this bit of script that controls the illuminated button, and sends a flag to my logic gauge to handle the hard stuff:
Code:
<PartInfo>
<Name>KA350i_EmerFreq_ON</Name>
<Visibility>
<Parameter>
<Code>
(L:KA350i_EmerFreq,bool)
(L:ANNUN_TEST,bool) or
</Code>
</Parameter>
</Visibility>
<MouseRect>
<Cursor>Hand</Cursor>
<MouseFlags>LeftSingle</MouseFlags>
<CallbackCode>
(L:KA350i_EmerFreq,bool) ! (>L:KA350i_EmerFreq,bool)
1 (>L:EmerFreqClicked,bool)
1 (>L:XMLSND5,bool)
</CallbackCode>
</MouseRect>
</PartInfo>
Code:
<Update>
<!-- COM EMER FREQUENCY -->
(L:KA350i_EmerFreq,bool)
(L:EmerFreqClicked,bool) and
if{
(A:COM ACTIVE FREQUENCY:1,MHz) (>L:ComActiveFreqBackup,enum)
@SetCOM1(121.50)
0 (>L:EmerFreqClicked,bool)
}
<!-- COM PREVIOUS FREQUENCY -->
(L:KA350i_EmerFreq,bool) !
(L:EmerFreqClicked,bool) and
if{
@SetCOM1((L:ComActiveFreqBackup,enum))
0 (>L:EmerFreqClicked,bool)
}
Code:
<Macro Name="SetCOM1">
@1 100 * near 10000 % d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (>K:COM_RADIO_SET)
</Macro>
</Update>


