I pretty sure that the first SELECT form is fastest, *when* you intend to process the entire file. It's only when you will want instant access, and may want to bail out on a condition that the BASIC SELECT is used. So that you can create LIST type access statements, where you can hit Q to end and you don't want to wait.
Otherwise the first form of SELECT would not exist. Who would want to wait for the entire file to be selected AND to be slower ?!!? Since the first select does all the gathering all at once, the system starts slapping the file into memory, and by the time you process it, it's all in the memory. The BASIC SELECT grabs a group and processes it, and grabs another and so the entire file never gets put into main memory until the O/S figures out you're going to process the whole file. I remember running multiple tests back in the late 80's and always found the SELECT to select the entire file, was always fastest even after multiple passes on the same file using different methods so that the file catching wasn't an issue in the difference in processing. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Derek Falkner Sent: Monday, December 13, 2004 14:28 To: [EMAIL PROTECTED] Subject: RE: [U2] LOOP or GOTO on READNEXT Karl, I am on thin ice here but, so far, nobody has stepped in with a better explanation, so I'll give it a try. Your first SELECT creates a list of items called the active select list. It takes a little while to construct as it reads the entire file in the process. The select list can then be saved, stored in a list variable or used in a READNEXT statement. Once the list is created it is static - no changes will be made to reflect new items as they are added to the file. The BASIC SELECT works differently I believe. It simply sets a pointer to the beginning of the first item in the first group in the file and this pointer is advanced after each READNEXT statement. The select statement doesn't have to read the whole file, so it is much faster than your first type of SELECT. It also implies that any new items added to groups which are ahead of the current pointer position will eventually be accessed by a READNEXT statement when the pointer has been advanced far enough. You can see there is no difference between the two types of SELECT provided the file is not being updated. That is what you observed. But try this: OPEN 'TEST' TO FILEVAR ELSE STOP 201, "No TEST file!" GET(ARG.) RUNTYPE ELSE RUNTYPE = 'TCL' BEGIN CASE CASE RUNTYPE = 'BASIC' CRT "Basic SELECT:" SELECT FILEVAR CASE RUNTYPE = 'TCL' CRT "TCL SELECT:" EXECUTE 'SELECT TEST' END CASE WRITE '%%%%%' ON FILEVAR, 'NON-EXIST-ID' ;* Item added AFTER the SELECT CNT = 0 ;* Now list the file using the select list LOOP READNEXT ID ELSE EXIT CNT += 1 CRT CNT'R#5 ':ID REPEAT STOP First count the TEST file, then RUN BP TEST.PGM TCL. You will notice the added item is not included in the list. If you remove the NON-EXIST-ID item and repeat the test but this time RUN BP TEST.PGM BASIC you will see that the new item IS included in the list. That is the difference! One last comment: don't believe all you read in the Pr1me INFO/Basic manual. They had it wrong too! Derek Falkner Kingston, Ontario, Canada. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 3:11 PM To: [EMAIL PROTECTED] Subject: RE: [U2] LOOP or GOTO on READNEXT <quote who="Dean Fox"> > Your understanding of the BASIC select is correct. It starts in group > one and works it's way down. In my early years of PICK programming I > learned this the hard way. As this user hasn't yet seen adverse > effects is luck vs. design. Okay, Bait taken. I just ran 2 programs. One that does: execute 'SELECT FILENAME' capturing NOTHIN and then one that does: select FILEVAR I had them print CNT and KEY as they looped through. Both lists were identical in order. Am I missing something? Karl > > Probably because of the a change to the least significant portion of > the ID (hash wise) and the number of groups vs. items, they're all > hashing to the same group after the ID change. > > In a similar test where the new ID would hash to a forward group, in > the code provided, it would be deleted. Been there, done that and now > know better. > > -[d]- > > -----Original Message----- > From: Derek Falkner [mailto:[EMAIL PROTECTED] > Sent: Monday, December 13, 2004 11:16 AM > To: [EMAIL PROTECTED] > 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/ > -- 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/