This example subroutine shows how to use the point returned by the minor word CURSOR in the IDENT statement. Many times the point returned must be mapped to the view, which is demonstrated in the following program.
PROC/L1,LPT,RESP
$$
$$ SUBROUTINE GET_LINE_ENDPOINT
$$
$$ SELECT A LINE, GET THE ENDPOINT
$$ CLOSEST TO THE CURSOR IN THE PROJECTION
$$ ON THE PLANE OF THE WORK VIEW
$$
$$ DECLARATIONS
ENTITY/L1
NUMBER/LPT(3),RESP
$$
ENTITY/VCSYS
NUMBER/CP(3),SPT(3),EPT(3)
NUMBER/VSPT(3),VEPT(3),VCP(3)
$$
$$ SELECT LINE
MASK/3
IDENT/'Select
Line',L1,CURSOR,CP(1),CP(2),CP(3),MEMBER,ON,RESP
IF/RESP <= 2, JUMP/L999:
$$
$$ GET LINE ENDPOINTS
OBTAIN/L1,SPT(1),SPT(2),SPT(3),EPT(1),EPT(2),EPT(3)
$$
$$ MAP CURSOR POSITION AND LINE ENDPOINTS TO
$$ THE VIEW WHERE THE CURSOR WAS USED
VCSYS = CSYS/&VWSEL
VSPT = MAP/SPT,FROM,&WCS,TO,VCSYS
VEPT = MAP/EPT,FROM,&WCS,TO,VCSYS
VCP = MAP/CP, FROM,&WCS,TO,VCSYS
$$
$$ GET DISTANCES (SQUARED) FROM LINE ENDPOINTS
$$ TO CURSOR AND COMPARE
$$ THESE ARE 2D DISTANCES
$$ COMPUTED ON THE VIEW PLANE
D1 = (VSPT(1) - VCP(1)) * (VSPT(1) - VCP(1)) $
+ (VSPT(2) - VCP(2)) * (VSPT(2) - VCP(2))
$$
D2 = (VEPT(1) - VCP(1)) * (VEPT(1) - VCP(1)) $
+ (VEPT(2) - VCP(2)) * (VEPT(2) - VCP(2))
$$
IFTHEN/ D1 > D2
LPT(1) = EPT(1)
LPT(2) = EPT(2)
LPT(3) = EPT(3)
ELSE
LPT(1) = SPT(1)
LPT(2) = SPT(2)
LPT(3) = SPT(3)
ENDIF
$$
L999:RETURN