G4 P1 is the same as Sleep(1000)
and I believe GetVar(2002) will only work if you use G31.
From the manual in the G31 section:
After successful probing, parameters 2000 to 2005 will be set to the coordinates of the
location of the controlled point at the time the probe tripped