You would have been able to diagnose this problem your self by putting error checks into the code, e.g.
Code:

? 'Error '+@ERROR+' - '+@SERROR


behind the READVALUE() and using either the /d flag or DEBUG ON in the beginning of your code. Stepping through your code you would have discovered that the script successfully passes the READVALUE() and chokes on the WRITEVALUE().
_________________________
There are two types of vessels, submarines and targets.