Programmer's Guide > Interfaces > ANode interface > distanceTo method
  
distanceTo method
Finds the distance from this Node to another specified Node.
distanceTo is intended to measure progress through a document in a reasonably linear manner. "Distance" is defined as the number of nodes between the nodes. Such measurements can be used for time estimates, progress dialog boxes, and so on.
If the target node is null, distanceTo calculates the distance to the end of the document. If the target node is not null, distanceTo calculates the distance to just before the target. Therefore, the sum of the distance between an arbitrary set of targets equals the total document distance, as long as each target is after the previous one.
distanceTo(toNode, expandTextEntities, expandFileEntities )
Parameters
NodetoNode
The Node to which the distance is to be measured.
booleanexpandTextEntities
Specifies whether or not text entities should be expanded when measuring the distance.
booleanexpandFileEntities
Specifies whether or not file entities should be expanded when measuring the distance.
Returns
long. Returns the distance between this Node and toNode. If the distance cannot be calculated, returns -1.