Karl,

You probably already know this, but the second example will never terminate.
I believe you intended to include a

LOOP WHILE DONE = 0 DO

or

LOOP UNTIL DONE DO

but the code does not include that necessary piece.  As to actual code
produced, I do not know.  However, I would recommend the following:

LOOP
   READNEXT K ELSE EXIT
   READ REC FROM CF, K THEN
      NK = FMT(K, "R%6")
      WRITE REC ON CF, NK
      DELETE CF, K
   END
REPEAT

This code is functionally the same as the piece with the GOTO, but without
the GOTO.  It has clear entry and exit, is tabbed for easy understanding,
and does not require an exit variable such as DONE.  I believe this will
translate to code virtually identical to the GOTO code and should operate at
the same speed.  The second piece of code you submitted, with the WHILE or
UNTIL added, has the additional burden of an IF (think WHILE or UNTIL) for
each iteration.

I hope that helps.

Thanks,


Dave Schexnayder.                       :-)
Cheetah Advanced Technologies, Inc.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Monday, December 13, 2004 9:33 AM
To: [EMAIL PROTECTED]
Subject: [U2] LOOP or GOTO on READNEXT


I've seen 2 ways to read a client key, change the length to 6 digits, then
write it back out, delete the old one and move on:

EXAMPLE 1 of 2:
!(FIXEMPNO) - Fix the employee number length
      open '','CUSTEMP' to CF else stopm 'Not'
      select CF
10:   readnext K else stop
      read REC from CF,K then
         NK = fmt(K,"R%6")
         write REC on CF,NK
         delete CF,K
      end
      go 10
   end

EXAMPLE 2 of 2:
!(FIXEMPNO) - Fix the employee number length
      DONE = 0
      open '','CUSTEMP' to CF else stopm 'Not'
      select CF
      loop
         readnext K else DONE = 1
      read REC from CF,K then
         NK = fmt(K,"R%6")
         write REC on CF,NK
         delete CF,K
      end
      repeat
   end

My intent is not to start a religious discussion about GO or GOTOs because
I see that method all over the place and regardless of why, who or
whatever, my question is, which is faster. (I prefer using loop..repeat
syntax, FWIW).

--
Karl L. Pearson
Director of IT,
ATS Industrial Supply
Direct: 801-978-4429
Toll-free: 800-789-9300 1,29
Fax: 801-972-3888
http://www.atsindustrial.com
[EMAIL PROTECTED]
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to