Moving in the opposite direction, stopping midway and returning to the starting point

Hello,

I’m new to RobotStudio. I am sitting on a task that involves the reverse movement of the robot, i.e. it follows a given path, the operator presses the button and the robot returns back to the point from which it left, but as soon as it presses it continues to move along the original path. I implemented the return to the original point. As well as the return to the continuation of the path is implemented. But I don’t understand how to interrupt the movement already in the interception procedure.
The code that I wrote:

TRAP reverseMove

StopMove \Quick;

p := CRobT(\Tool:=tool0);

StorePath;

ClearPath;

MoveAbsJ Targets{Stage - 1},
v500, z50, tool0;

MoveJ p, v500, z50, tool0;

RestoPath;

StartMove;

ENDTRAP

CONNECT ROB1_path_reverse WITH reverseMove;

ISignalDI TES_PP, 1, ROB1_path_reverse

Thank you in advance for any help!

Read up on the Pathrecorder instructions.

Greetings, I appreciate your attention. However, the question of stopping in the middle of the path remains unresolved in interrupting.