If You correct the second example so the loop stops when the list is exhausted
it will be the same.
They are very likely to compile to exactly the same pseudo-code.
And even if they don't the body of the loop is so heavy, having a write and a read
and a delete in it, so You've no chance whatsoever of ever noticing the difference.


For timing issues regard a read as calling a subroutine with hundreds of executed lines
and a write or delete as even larger.
Not to speak of those times when the logical read/write results in physical I/O
and not only operates in the buffers - then we are talking _milliseconds_
and any difference between Your examples would be a nano-seconds
- in both cases per iteration.


-- mats

[EMAIL PROTECTED] wrote:

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).
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to