Use DEBUG ON to step through your code. Also, please rad up on variable scoping and use SETOPTION('Explicit','on') to prevent problems with variable scoping.

Also, take a look at the content of $PSTPATH and don't use variables inside strings, it's a bad practice.
_________________________
There are two types of vessels, submarines and targets.