Global variable (Multisport Distance) for Swimrun/Multisport activity?

Hi

I am completely new to the Garmin development world so question might be somewhat vague...

I want to create a data field to be used during a multisport activity that would hold the total distance of all the activities. In my primary case it will hold the distance of all swim and run activities during a swimrun race. In swimrun you swim-run-swim-run-swim... You get it. Today you can get a data field for Multisport Time, that holds the total time for all activities, but not for distance...

For this to work I guess I need a global variable that would hold this value as you change from run to swim and back ...

Anyone that is familiar with the options in the programming language, or a similar code example