Steve: Please take a long hard look at the KiXtart Manual and notice the correct syntax for commads like IF-ENDIF, SELECT-CASE-ENDSELECT and so on. If you then start indenting your code you will notice very easily why your code doesn't work.

However, you code will require major rework anyway because the way you use the IFs is illogical, you don't want to have them nested at all.
_________________________
There are two types of vessels, submarines and targets.