ALT HOLD - PITCH HOLD Switch coding question

Hi. I don’t know where to put this question since it is about xml with RPN.
I’m trying to create a switch that in one position activates alt hold and in
the other position activates pitch hold but also holds the current pitch
attitude. I have solved some problem along the way but I still can’t get that
when hooking pitch hold hold the current pitch. I currently have this:
(L:ALT_HOLD, Bool) ! (>L:ALT_HOLD) (L:ALT_HOLD, Bool) if{ (A:AUTOPILOT PITCH
HOLD, Bool) if{ (>K:PITCH_LEVELER_OFF) } (A:AUTOPILOT ALTITUDE LOCK, Bool) !
if{ (>K:AP_ALT_HOLD) } } (L:ALT_HOLD, Bool) ! if{ (A:AUTOPILOT ALTITUDE LOCK,
Bool) if{ 0 (>K:AP_ALT_VAR_SET_ENGLISH) (>K:AP_ALT_HOLD_OFF) } (A:AUTOPILOT
PITCH HOLD, Bool) ! if{ (>K:PITCH_LEVELER_ON) (A:PLANE PITCH DEGREES, degrees)
(>K:AP_PITCH_REF_SET) } } The reason the code resets the target altitude to 0
is because pitch hold cannot be activated while the target altitude matches
the current altitude, so there is no really a problem. The real problem is
that I can’t find a way for (>K:AP_PITCH_REF_SET) to take the current pitch
value that I want. Can you advise me what value should go after (A:PLANE PITCH
DEGREES, degrees) or before (>K:AP_PITCH_REF_SET)? Thanks.