This is how I do toggle buttons.
In BtnTop.txt I add a line for the button
Code:
expr: "startcode('M910')" "" image="Icons/IMG_Compressor.svg" tooltip="Compressor" imagechange="true" stroke=3.0 updown="_compressor == 1" updatefast="true"
This will use the variable _compressor to maintain the state. The you need to create a script file something line this:
Code:
(print,Start M910)
O<Test> if[NOTEXISTS[#<_compressor>]]
#<_compressor> = 0
O<Test> endif
O<Toggle> if[#<_compressor>]
#<_compressor> = 0
M63 P1 Q0
O<Toggle> else
#<_compressor> = 1
M63 P1 Q50
O<Toggle> endif
(print,End M910)
Hope this helps. Once again I suggest using svg's for you buttons as they scale properly if you change the size of the toolbar.
Simon