Change the TCP Position in Rapid

Hy there,
I want to write a Programm for a Spraying Process. One of the Spraying parameters is the distance to the workobjekt. Is it possible to change the TCP Position from the spraying gun, perhaps with a variable in the Rapid code? Or is there any other way to do this? The reason for this is that it is necessary to change the spraying distance a few times for the same path. So with a variable in the Code I could change the distance directly online.

Thanks guys

you can edit the tool in rapid to acheive this.

or possibly create multiple tools and switch between them.

You could try something like this:

Tool_temp:=Tool_spray;
FOR i FROM 10 TO 30 STEP 10
tool_temp.trans.z:=tool_temp.trans.z+i;
MoveL p10, v1000, z10, tool_temp;

MoveL p20, v1000, z10, tool_temp;
ENDFOR