There is the option 611-1 Path Recovery. You could technically use it to check for this, based on the following chart from the documentation:
To get this to work, you would need to start a recording and stop it before it can be used to check if the robot has moved off-path.
VAR pathrecid origin_id; !Define a path recorder id
PathRecStart origin_id;
MoveJ p1, vmax, z50, tool1;
MoveL p2, vmax, fine, tool1;
PathRecStop;
Stop \NoRegain; !Don't ask to move back when restarting program
IF (PathRecValidBwd(\ID:=origin_id) = TRUE) THEN
!Robot has a valid path backwards, meaning it is still on path. Reset output
Reset doRobotOffPath;
ELSE
!Robot does not have a valid path backwards, robot has been moved since path recorder stopped. Set output
Set doRobotOffPath;
ENDIF
Display More
If you don't have access to that option, you could write a function that returns the shortest distance to a line defined by 2 points. Here's something that could work:
FUNC num PerpendicularDistance(pos Point, pos LineStart, pos LineEnd)
VAR num nDotProduct;
VAR num nLineLength;
VAR pos psLineUnitVector;
VAR pos psLineVector;
VAR pos psPerpendicularVector;
VAR pos psPointVector;
VAR pos psProjection;
psLineVector := LineEnd - LineStart;
psPointVector := Point - LineStart;
nLineLength := Sqrt(Pow(psLineVector.x, 2) + Pow(psLineVector.y, 2) + Pow(psLineVector.z, 2));
psLineUnitVector := [(psLineVector.x / nLineLength), (psLineVector.y / nLineLength), (psLineUnitVector.z / nLineLength)];
nDotProduct := DotProd(psPointVector, psLineUnitVector);
psProjection := [(psLineUnitVector.x * nDotProduct), (psLineUnitVector.y * nDotProduct), (psLineUnitVector.z * nDotProduct)];
psPerpendicularVector := psPointVector - psProjection;
RETURN (Sqrt(Pow(psPerpendicularVector.x, 2)) + (Pow(psPerpendicularVector.y, 2)) + (Pow(psPerpendicularVector.z, 2)));
ENDFUNC
Display More
You could use this by getting the robot's current position and checking it against the part of the path defined by 2 other robtargets:
PROC PathMonitor()
VAR num nTolerance:=3;
VAR num nDistToPath;
VAR robtarget pPoint1;
VAR robtarget pPoint2;
VAR robtarget pCurrPoint;
pCurrPoint:=CRobT(\Tool:=tool1);
nDistToPath:=PerpendicularDistance(pCurrPoint.trans, pPoint1.trans, pPoint2.trans);
IF (nDistToPath < nTolerance) THEN
!Robot is within tolerance to set path. Reset output
Reset doRobotOffPath;
ELSE
!Robot is outside tolerance to set path. Set output
Set doRobotOffPath;
ENDIF
ENDPROC
Display More
There are downsides to this approach. You will need to know exactly which 2 points of the path you want to check and corner zones aren't accounted for, but maybe it could be useful.