Er, the first line of the code sets netName, so presumably you didn't cut and paste it, or omitted that part and didn't set it yourself...
Of course "iref" is not necessarily the name you want.
You could of course change it to be a function definition:
; select all the wire segments on the net
foreach(fig net~>figs geSelectFig(fig))
; print connections
printf("Net %s is connected to:\n" netName)
printf(" Pin %s of instance %s (cell %s)\n"
instTerm~>name instTerm~>inst~>name instTerm~>inst~>cellName
And then use: