Distance measurement and extracting data

Hi, I’m new to programming in rapid. I have a question about distance measurement.

I have created targets for my robot, and then I want to record the position of the TCP after it has moved to each target. Here is a snippet of my code:

MoveL Target_200,v1000,fine,EndEffector3\WObj:=Workobject_1;
TCPPos1 := CPos(\Tool := EndEffector3 \WObj := Workobject_1);
dist2 := Distance(TCPPos1, measurementPoint);

MoveL Target_210,v1000,fine,EndEffector3\WObj:=Workobject_1;
TCPPos2 := CPos(\Tool := EndEffector3 \WObj := Workobject_1);
dist3 := Distance(TCPPos2, measurementPoint);

MoveL Target_220,v1000,fine,EndEffector3\WObj:=Workobject_1;
TCPPos3 := CPos(\Tool := EndEffector3 \WObj := Workobject_1);
dist3 := Distance(TCPPos2, measurementPoint);

MoveL Target_230,v1000,fine,EndEffector3\WObj:=Workobject_1;
TCPPos4 := CPos(\Tool := EndEffector3 \WObj := Workobject_1);
dist4 := Distance(TCPPos2, measurementPoint);

for dist1,..,4 I get the same distance as in the first one, even though I can see in the flexpendant that TCPPos1,…,4 are different, so it should be different distances as well.

Thas is my first concern. My second concern is if there is a way to extract the data TCPPo1,…,4 in any way from RobotStudio for analysing the data?

Hi…
There are some inconsistencies in your code…
Having a look, that might be the problem.

??? dist3 := Distance(TCPPos2, measurementPoint) === dist4 := Distance(TCPPos2, measurementPoint);

Good Work.

I realised this when working with the program, I think the syncronization messed up my code. Thank you for your answer.