I agree. Be careful to not trip over a record written in later frames. Although WRITE after DELETE prevents the problem.
I have an observed question. Is there any MV flavor that requires the null expression for DICT with opening the DATA level of a file. I stopped using that unnecessary code over 20 years ago and don't think it's required anywhere. Plus, all seem to support OPEN "DICT CUSTOMER" having both in one pair of quotes without the comma. The OPEN "","CUST" just looks extraneous and illustrates being taught something once and not realizing that the teacher may have been limited. Just asking. ----- Original Message ----- From: "Derek Falkner" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 13, 2004 11:15 AM Subject: RE: [U2] LOOP or GOTO on READNEXT > Karl, > > I cannot speak to the issue of speed but I am concerned about the safety of > either process; I believe you may end up with missing employees! > > I believe the BASIC SELECT sets a pointer at the start of group 1 and steps > it through each item in that group before moving on to group 2. What could > happen is that the record with the new 6 digit key is written to a later > group and the item with the old key is deleted. Later, the SELECT would pick > up the new employee and, even though it already has a 6-digit key, would > write it back to the file and then immediately delete it! > > I would prefer to see a TCL-style SELECT be performed instead of the BASIC > SELECT, e.g. PERFORM "SELECT CUSTEMP" instead of SELECT CF. This will > definitely not select any of the newly-created items, though it would also > fail if any employees on file already had 6-digit keys. > > Alternatively, you could check the new item key differs from the original > item key before deleting an item. > E.g. write REC on CF,NK > if K # NK then > delete CF,K > end > > If my understanding of the BASIC SELECT is wrong I would be happy if someone > on this list could enlighten me. > > Oh, and I must add that I much prefer the LOOP ... REPEAT syntax too! I > wouldn't imagine there would be much difference in speed and I find it > easier to write/debug. > > Thanks for the interesting question! > > Derek Falkner > Kingston, Ontario, Canada > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Monday, December 13, 2004 10: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/ ------- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
