thanks elogesh and structur71, here is the final version:
/prep7
*ask,kp1
*ask,kp2
chk1=ksel(kp1)
chk2=ksel(kp2)
*if,chk1,eq,0,or,chk2,eq,0,then
*msg,ui
One or both of entered key points do not exist.
*else
ksel,s,kp,,kp1
ksel,a,kp,,kp2
lslk,s,1
lnum=lsnext(0)
*if,lnum,eq,0,then...