Oh my goodness, I did all of that so long ago I forgot what I learned for the Starship and the Dukes. There's a much simpler way to go about it.
//Black Square/TBM/Autopilot
Pilot_CWS_Down#1 (>L:var_PilotCws_IsDown, bool)
Pilot_CWS_Up#0 (>L:var_PilotCws_IsDown, bool)
//Black Square/TBM/Engine
850_Mode_On#1 (>L:var_850Mode, bool)
850_Mode_Off#0 (>L:var_850Mode, bool)
Put that into a file in your FSUIPC directory called myevents.txt. If it doesn't exist, create it. From the Buttons and Switches Assignment screen, select your button, do your profile stuff (you really should so that it auto loads profiles depending on what aircraft you load), then just click Find Preset for both press and release.
[image: b612622a-9af1-47a2-b01c-7cd834a51949.png]
It will be under Personal-->Black Square-->TBM and so on based on how it is listed in myevents.txt. How to set it is already done in the so-called "calculator code" I have above in the snipped that goes into myevents.txt. CWS_Down will always send a 1, CWS_Up will always send a 0. There is some very powerful RPN coding possible in there that I haven't yet been able to make heads or tails of, but this is a simple enough way that it should get you up and running pretty quickly.
[image: 67b9e665-5bbb-44e5-9faf-9b58a5c95ecd.png]