There are probably many ways to do this. I have had success using binary values.
;SETTING # VALUE TO HOME POSITION
;DECIMAL NUMBER 0
LOCALKUKATOHMI = 'B00000000'
Here is an example above. Basically after whatever move you do you set the binary value to what you want. Then have a homeout interrupt routine that runs through and looks for that number, and based upon the number you program it to do certain moves to return home. Below is an example of the homeout routine code.
;---------------
;BEFORE LEFT PART PICK
IF LOCALKUKATOHMI == 1 THEN
;PTP P1
PTP XHOME
ENDIF
;---------------