Thank you!
I didn't expect a solution.
Something else I notice now.
For the first marker at the start I have to use XSectionLength, afterwards XSectionNextLength.
Return if(Linear_1S1.XSplinePosition==0.0, Linear_1S1.XSectionLength, Linear_1S1.XSectionNextLength);
Otherwise the segment at the start takes the length of the next section.