George Gallen wrote:
> ok...I found this code snipit (REALITY FLAVOR)
> 
> SELECT FILENAME
> LOOP
>    READNEXT ID ELSE EXIT
> WHILE ID DO
>    CODE
>    CODE with GOSUB
>    CODE
>    CODE
> REPEAT
> 
> 
> What was happening was the loop was exiting early,  but it was exiting after
> the
> CODE with GOSUB line was executed.
> 
> What struck me was why there was a While DO as well as an EXIT in the loop?
> while nothing in the CODE or GOSUBs modified the ID, would having both the
> WHILE/DO and EXIT cause some kind of problem?
> 
> After I removed (commented out) the WHILE/DO line, the program ran as
> expected
> and processed the 100,000 records, (whereas before it stopped after 6).

While the code itself is less than elegant, I strongly suspect that the
exiting lies in what's being done in the GOSUB.  Perhaps it's doing a
SELECT or a CLEARSELECT, or something else that corrupts the active
select list.

I recently saw a piece of code where the active select list was trashed
because the code opened a file, then executed a create-file on the
opened file...  Took us a while to figure that one out.

As for the loop structure, I tend to like this:
SELECT FILENAME
LOOP WHILE READNEXT ID
  CODE
  CODE
  CODE with GOSUB
  CODE
  CODE
REPEAT

It's clean, it's concise, it's easy to read...  And I wish I could
remember who taught me that you could combine the LOOP and READNEXT in
that manner...

-- 
Allen Egerton
aegerton at pobox dot com
PGP Key ID 0x8EA57261
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to