Hmm..

The GOTO isn't exiting the loop, but is short-circuiting the SELECT.

Simple change:

While @ERROR=0
:TOP
$FLAG=0
Select
Case (whatever you need..)
set some value...
$FLAG=1
Case (something else...)
More Code...
$FLAG=1
EndSelect
If $FLAG = 1 goto TOP

; if no chages via CASE, $FLAG will still be zero

More end of loop code....

Loop ; get next data

This lets the select / endselect work properly while preserving your logic.

Another method might be to embed a loop around the select, looping as long as changes are made. From your last message, it sounds like this may be what you did.

While @ERROR=0
$FLAG=1 ; continue subloop until cleared
While $FLAG=1
Select
Case test_1
do stuff...
Case test_2
do different stuff..
Case 1 ; we didn't do anything, so clear FLAG
$FLAG=0
EndSelect
Loop ; while FLAG=1
Loop ; while ERROR=0

Remember that only the first match in a case is executed, even if others are true. Thus, after continuously chopping the leading chars off, when you no longer match anything, the "1" will match as a default - changing the FLAG value and terminating the inner loop. In both examples, the EndSelect is reached for each iteration. This is where the problem may have arisen - too many SELECTs were opened.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D