I'm afraid your code is wrong. Basic4ppc can't handle compound references to properties and methods like "gw.Sprite1.ID". The IDE doesn't error this but returns 0 or an empty string. The optimising compiler will however error it, though not with a helpful message. You need to use this code.
Code:
Sub gw_collision
Spr1.value=Gw.Sprite1
Spr2.value=Gw.Sprite2
label3.Text=Spr1.ID
label4.Text=Spr2.ID
...