There is a built in method called distance. Below is it's usage:
distance(Position1.X, Position1.Y, Position2.X, Position2.Y)
This returns a decimal value of the length of the line between the 2 points. If you need a distance along a path which changes directions, you could simply sum up all the values of the distances between each change of direction:
distance(p1.X, p1.Y, p2.X, p2.Y) + distance(p2.X, p2.Y, p3.X, p3.Y) + distance(p3.X, p3.Y, p4.X, p4.Y) etc...
To get more information, do a search in the manual. You will find all you need to know about the distance method.