Another thing to look at:
If what I read in the language guide is correct, then your IF..THEN statements are actually branching to a non-existent program label called gosub:
Is it possible to compile that without raising an error?
You may have to remove the GOSUBs and the ENDIFs from this bit of code (better make a copy of it lol):
if cmd = "0" Then
GOSUB bad
endif
if cmd = "1" Then
GOSUB dosleep
endif
if cmd = "2" Then
GOSUB doend
endif
if cmd = "3" Then
GOSUB getname
endif
if cmd = "4" Then
GOSUB dispname
endif
Assuming that the manual is correct, I can see why your blocks of IF..ENDIF are not working (not legal), but I am surprised if the compiler isn't catching that!
Is it possible that your PIC is resetting when it encounters the first illegal IF..THEN construct? It would explain everything..
Bookmarks