RE: [U2] LOOP or GOTO on READNEXT [END OF THREAD]
This thread is now officially ended. You have been instructed to take it to u2-community. Larry Hiscock Moderator -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hanwell, David Sent: Thursday, December 30, 2004 8:29 AM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT GOTO falls under the category of religion As The Grand PooBah of the Church Of Where-Do-I-GOTO, I, The Reverend Rabbi Ayatollah Davey Ben Davey, deeply resent the slur upon the fine religion of Where-Do-I-GOTO by knaves and fools who know nothing of its theology. This violation of Political Correctness can only be removed by you, Mr. Charles Barouch, Atheist Moderator of Sin and spawn of Satan, educating yourself on the moral, philosophical, spiritual, and hedonistic principles of the exemplary Church Of Where-Do-I-GOTO. I recommend my treatise The Quim, or The Elementary Principals of the Church Of Where-Do-I-GOTO and Why Infidels Claim We Observant Worshippers Are Doomed to an Eternal LOOP RETURN. You can find this outstanding theological work in Volume XXX of Larry Flynn's Hustler collection of objects d'art, dated December 32, 1993. My work has been nominated for the Nobel Prize in Theology for 11 consecutive years, but unfortunately, when I nominate myself, nobody seconds it. So just remember this: For infidel know you have trod on the toe of The Reverend Rabbi Ayatollah Davey Ben Davey. Debster, please send a case of eggnog-and-rum bottles to me, The Reverend Rabbi Ayatollah Davey Ben Davey. We Observants quaff this libation throughout our services except for Communion, where we honor Margarita, Mother of the Church Of Where-Do-I-GOTO by drinking from a clay chalice containing a tequila-lemon-salt concoction. Justice is incidental to law and order. - J. (John) Edgar Hoover (1895 - 1972) David Hanwell -Original Message- From: [EMAIL PROTECTED] On Behalf Of Debster Sent: Wednesday, December 29, 2004 11:26 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Chuck ok... Calm down Take an egg nog in hand and sip slowly We will take heed and GOTO to the community list and hope it does not do a LOOP RETURN... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Moderator Sent: Wednesday, December 29, 2004 6:33 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] LOOP or GOTO on READNEXT ONCE AGAIN: MOVE THIS TO U2-COMMUNITY! This belongs on U2-Community, not on U2-Users. GOTO falls under the category of religion and this is a technology mailing list. Off-topic matters belong on U2-Community. - Charles Barouch, Moderator [EMAIL PROTECTED] - U2-Users Moderator -- To subscribe to the u2-users or u2-community mailing lists or digest lists, send one or more of the following lines in the BODY (not the subject) of an email addressed to [EMAIL PROTECTED] subscribe u2-users subscribe u2-users-digest subscribe u2-community subscribe u2-community-digest --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ CONFIDENTIALITY This e-mail and any attachments are confidential and also may be privileged. If you are not the named recipient, or have otherwise received this communication in error, please delete it from your inbox, notify the sender immediately, and do not disclose its contents to any other person, use them for any purpose, or store or copy them in any medium. Thank you for your cooperation. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
if you venture deep into some of the low level time functions in *nix ( aka C code) you'll find goto's... This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
I'm an elder too...so I will be kind to myself.. alas...everyone missed my point.. Personally...and I mean personally, even if I hoards behind me who feel the same way...I think GO, GOTO's are sloppy coding. There are cleaner ways to do it. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Bruce Nichol Sent: Tuesday, December 28, 2004 9:33 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Goo'day, At 19:30 28/12/04 -0500, you wrote: It is a silly argument... I just think about utilizing a goto or its facsmile within C++. C, C# (not that I ever did) and it would quickly garner a big red F in school... Ah! But some of us were programming top down with GO's, JUMP's, what-have-you - quite productively and successfully - long before structured programming was foisted upon an unsuspecting public, and long before schools of any ilk, primary, secondary or tertiary, even knew a skerrick about programming per se. Most of the programming profession in those days, and it's well and truly within my lifetime, were taught their trade by hardware manufacturers. As a matter of small fact, top down programming was preached at me in my early Pick days (late 70's) to overcome frame faulting/ response time problems in MDD boxes with only 32K of memory and up to 8 users Be kind to your elders. I don't know of any other language where it would even get beyond a snicker at the unpolished newbie... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 5:27 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. The elapsed time of each test could have been different enough that the differences in the counts would fall within that margin of error. This is particularly noticeable in Tom's test below. Using 'TIME() + some.number' to determine the stopping point could make the first iteration up to .999 seconds shorter than the second. When you're processing hundreds of thousands or millions of iterations per second, that fraction of a second could account for the differences. Using Tom's example below, if the system time was 1.999 at the start, then ETIME for the first pass would be 10005, resulting in 4.001 seconds of processing. The second pass would start around 10005.001 and ETIME would be 10010, resulting in 4.999 seconds of processing. When processing 600,000 iterations, that means a margin of error of 120,000. Hence the results are skewed toward the second loop. To get around this, you could: A) Use SYSTEM(12)(on UD) to get milliseconds or other function to get a more exact measurement of time to make margin of error smaller. B) Add some code at the beginning to ensure TIME() had just incremented to the next number before starting a loop. C) Loop for more than a few seconds to make the partial second a smaller part of the total. D) Loop for a fixed number of times, logging starting and ending times (preferably in milliseconds or smaller). Dean P.S. I apologize for the late post. I'm once again way behind but couldn't resist this one. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:32 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood [EMAIL PROTECTED] wrote on 13 Dec 2004 09:36:42 -0800 I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! ... So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03:CTR = 0 04:ETIME = TIME() + 5 05:LOOP WHILE TIME() ETIME DO 06: CTR += 1 07:REPEAT 08:PRINT While :CTR 09: * 10:CTR = 0 11:ETIME = TIME() + 5 12: 10 CTR += 1 13:IF TIME() ETIME THEN GOTO 10 14:PRINT Go To :CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results (W indicates Winner :-) -- Go To First - -- While First - Go To Count While Count Go To Count While Count --- --- --- --- 769730 W 752380667050 W 458545 655809 734709 W 747373 W 592827 576565 688953 W 785676 W 611628 629807 748265 W 714679 W 564908 The second loop for whatever reason seems to have an advantage. Overall, I
Re: [U2] LOOP or GOTO on READNEXT
The very essence of programming is go to and address arithmetic. That was the dramatic breakthrough of stored programming vs card programming in the early fifties. You could loop with a Card programmed Calculator by pulling the cards out of the stacker, substituting some new entries at the bottom of the calculations and then putting the deck back through. But with the arrival on the commercial scene of the Univac and the IBM 701 you could loop by doing arithmetic on an address since it was just another number stored in a register. (The big argument among the two schools of programmers of that day was if TRF was superior to JUMP. TRF was the IBM version of GOTO while JUMP was the Univac version). In the late fifties Fortran was hard to learn because you could not access the addresses directly and had to trust the language to take care of that sort of thing. There were several independent modifications to Fortran to give what is approximately the Exit in modern languages - and that is nothing more or less than a GOTO. Real programmers modify addresses and use many GOTOs. That way they have a job forever :) BobJ - Original Message - From: Peter D Olson [EMAIL PROTECTED] To: u2-users@listserver.u2ug.org Sent: Wednesday, December 29, 2004 7:44 AM Subject: RE: [U2] LOOP or GOTO on READNEXT if you venture deep into some of the low level time functions in *nix ( aka C code) you'll find goto's... This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
Debster [EMAIL PROTECTED]@[EMAIL PROTECTED] wrote on 12/28/2004 07:30:37 PM: It is a silly argument... I agree :) --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
spare us please. I think the posters were referring to days gone by AND coding closer to the machine. Have a look at most any assembler language, you'll find things like jumps (goto's in disguise). Don Kibbey Financial Systems Manager Finnegan, Henderson, Farabow, Garrett Dunner LLP [EMAIL PROTECTED] 12/29/04 08:37AM I'm an elder too...so I will be kind to myself.. alas...everyone missed my point.. Personally...and I mean personally, even if I hoards behind me who feel the same way...I think GO, GOTO's are sloppy coding. There are cleaner ways to do it. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Bruce Nichol Sent: Tuesday, December 28, 2004 9:33 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Goo'day, At 19:30 28/12/04 -0500, you wrote: It is a silly argument... I just think about utilizing a goto or its facsmile within C++. C, C# (not that I ever did) and it would quickly garner a big red F in school... Ah! But some of us were programming top down with GO's, JUMP's, what-have-you - quite productively and successfully - long before structured programming was foisted upon an unsuspecting public, and long before schools of any ilk, primary, secondary or tertiary, even knew a skerrick about programming per se. Most of the programming profession in those days, and it's well and truly within my lifetime, were taught their trade by hardware manufacturers. As a matter of small fact, top down programming was preached at me in my early Pick days (late 70's) to overcome frame faulting/ response time problems in MDD boxes with only 32K of memory and up to 8 users Be kind to your elders. I don't know of any other language where it would even get beyond a snicker at the unpolished newbie... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 5:27 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. The elapsed time of each test could have been different enough that the differences in the counts would fall within that margin of error. This is particularly noticeable in Tom's test below. Using 'TIME() + some.number' to determine the stopping point could make the first iteration up to .999 seconds shorter than the second. When you're processing hundreds of thousands or millions of iterations per second, that fraction of a second could account for the differences. Using Tom's example below, if the system time was 1.999 at the start, then ETIME for the first pass would be 10005, resulting in 4.001 seconds of processing. The second pass would start around 10005.001 and ETIME would be 10010, resulting in 4.999 seconds of processing. When processing 600,000 iterations, that means a margin of error of 120,000. Hence the results are skewed toward the second loop. To get around this, you could: A) Use SYSTEM(12)(on UD) to get milliseconds or other function to get a more exact measurement of time to make margin of error smaller. B) Add some code at the beginning to ensure TIME() had just incremented to the next number before starting a loop. C) Loop for more than a few seconds to make the partial second a smaller part of the total. D) Loop for a fixed number of times, logging starting and ending times (preferably in milliseconds or smaller). Dean P.S. I apologize for the late post. I'm once again way behind but couldn't resist this one. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:32 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood [EMAIL PROTECTED] wrote on 13 Dec 2004 09:36:42 -0800 I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! ... So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03:CTR = 0 04:ETIME = TIME() + 5 05:LOOP WHILE TIME() ETIME DO 06: CTR += 1 07:REPEAT 08:PRINT While :CTR 09: * 10:CTR = 0 11:ETIME = TIME() + 5 12: 10 CTR += 1 13:IF TIME() ETIME THEN GOTO 10 14:PRINT Go To :CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results (W indicates Winner :-) -- Go To First - -- While First - Go To Count While Count Go To Count
RE: [U2] LOOP or GOTO on READNEXT
IF i WHILE and LOOP and NOT GOTO the doctors I will WEND up in the hospital. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 5:27 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT While quibbling over nanoseconds, ... --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
the use of goto's or lack of shouldn't be a judge of sloppy coding . sloppy coding is just sloppy coding. remember one persons slop is another persons pudding :) example 1: y=0 loop readnext z else y = 1 if y = 1 then exit do stuff repeat more stuff vs example 2: 10: readnext claim_id else goto 20 do stuff goto 10 20: more stuff vs example 3 loop readnext claim_id else exit do stuff repeat more stuff LoopForEver This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
I love it when folks use a loop to add up vm's. And not the simple Sum command. Seen that a bit in the code I work in. Goto's never bother me. I came from a 4GL language called Ezgen, and it only had GO'tos. Had no such thing as gosub. The only way to do a gosub type is to make it a called program. We did that for routines that are used multiple times, no gosubs. I am getting out of the habit and only use go-tos' when I really feel there is cause. Took a bit though :). Thanks, Marilyn A. Hilb Value Part, Inc Direct: 847-918-6099 Fax: 847-367-1892 [EMAIL PROTECTED] www.valuepart.com -Original Message- From: Peter D Olson [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 29, 2004 9:12 AM To: u2-users@listserver.u2ug.org Subject:RE: [U2] LOOP or GOTO on READNEXT the use of goto's or lack of shouldn't be a judge of sloppy coding . sloppy coding is just sloppy coding. remember one persons slop is another persons pudding :) example 1: y=0 loop readnext z else y = 1 if y = 1 then exit do stuff repeat more stuff vs example 2: 10: readnext claim_id else goto 20 do stuff goto 10 20: more stuff vs example 3 loop readnext claim_id else exit do stuff repeat more stuff LoopForEver This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
I have to weigh in on this a bit. The issue with GOTOs is not one of performance (as someone else pointed out a loop compiles down to GOTOs at a low level) nor is it an instant sign of sloppy code. The problem is that it is far easier to degrade into sloppy code. In a complex program it can make a program much tougher to read maintain for any programmer that follows the original author. Rich Taylor | Senior Programmer/Analyst| VERTIS 250 W. Pratt Street | Baltimore, MD 21201 P 410.361.8688 | F 410.528.0319 [EMAIL PROTECTED] | http://www.vertisinc.com Vertis is the premier provider of targeted advertising, media, and marketing services that drive consumers to marketers more effectively. The more they complicate the plumbing the easier it is to stop up the drain - Montgomery Scott NCC-1701 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter D Olson Sent: Wednesday, December 29, 2004 10:12 AM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT the use of goto's or lack of shouldn't be a judge of sloppy coding . sloppy coding is just sloppy coding. remember one persons slop is another persons pudding :) example 1: y=0 loop readnext z else y = 1 if y = 1 then exit do stuff repeat more stuff vs example 2: 10: readnext claim_id else goto 20 do stuff goto 10 20: more stuff vs example 3 loop readnext claim_id else exit do stuff repeat more stuff LoopForEver This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
Please move this to U2-Community. - Charles Barouch, Moderator -- Original Message - Subject: RE: [U2] LOOP or GOTO on READNEXT Date: Wed, 29 Dec 2004 10:00:09 -0600 From: Marilyn Hilb [EMAIL PROTECTED] To: u2-users@listserver.u2ug.org I love it when folks use a loop to add up vm's. And not the simple Sum command. Seen that a bit in the code I work in. Goto's never bother me. I came from a 4GL language called Ezgen, and it only had GO'tos. Had no such thing as gosub. The only way to do a gosub type is to make it a called program. We did that for routines that are used multiple times, no gosubs. I am getting out of the habit and only use go-tos' when I really feel there is cause. Took a bit though :). Thanks, Marilyn A. Hilb Value Part, Inc Direct: 847-918-6099 Fax: 847-367-1892 [EMAIL PROTECTED] www.valuepart.com -Original Message- From: Peter D Olson [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 29, 2004 9:12 AM To: u2-users@listserver.u2ug.org Subject:RE: [U2] LOOP or GOTO on READNEXT the use of goto's or lack of shouldn't be a judge of sloppy coding . sloppy coding is just sloppy coding. remember one persons slop is another persons pudding :) example 1: y=0 loop readnext z else y = 1 if y = 1 then exit do stuff repeat more stuff vs example 2: 10: readnext claim_id else goto 20 do stuff goto 10 20: more stuff vs example 3 loop readnext claim_id else exit do stuff repeat more stuff LoopForEver This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
ahhh yesand Avante/SB+ in their infinite wisdom...zippo gosubs in paragraphs...lets repeat ourselves unecessairly! -- Debster -- Original message -- I love it when folks use a loop to add up vm's. And not the simple Sum command. Seen that a bit in the code I work in. Goto's never bother me. I came from a 4GL language called Ezgen, and it only had GO'tos. Had no such thing as gosub. The only way to do a gosub type is to make it a called program. We did that for routines that are used multiple times, no gosubs. I am getting out of the habit and only use go-tos' when I really feel there is cause. Took a bit though :). Thanks, Marilyn A. Hilb Value Part, Inc Direct: 847-918-6099 Fax: 847-367-1892 [EMAIL PROTECTED] www.valuepart.com -Original Message- From: Peter D Olson [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 29, 2004 9:12 AM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT the use of goto's or lack of shouldn't be a judge of sloppy coding . sloppy coding is just sloppy coding. remember one persons slop is another persons pudding :) example 1: y=0 loop readnext z else y = 1 if y = 1 then exit do stuff repeat more stuff vs example 2: 10: readnext claim_id else goto 20 do stuff goto 10 20: more stuff vs example 3 loop readnext claim_id else exit do stuff repeat more stuff LoopForEver This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
ONCE AGAIN: MOVE THIS TO U2-COMMUNITY! This belongs on U2-Community, not on U2-Users. GOTO falls under the category of religion and this is a technology mailing list. Off-topic matters belong on U2-Community. - Charles Barouch, Moderator [EMAIL PROTECTED] - U2-Users Moderator -- To subscribe to the u2-users or u2-community mailing lists or digest lists, send one or more of the following lines in the BODY (not the subject) of an email addressed to [EMAIL PROTECTED] subscribe u2-users subscribe u2-users-digest subscribe u2-community subscribe u2-community-digest --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
Chuck ok... Calm down Take an egg nog in hand and sip slowly We will take heed and GOTO to the community list and hope it does not do a LOOP RETURN... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Moderator Sent: Wednesday, December 29, 2004 6:33 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] LOOP or GOTO on READNEXT ONCE AGAIN: MOVE THIS TO U2-COMMUNITY! This belongs on U2-Community, not on U2-Users. GOTO falls under the category of religion and this is a technology mailing list. Off-topic matters belong on U2-Community. - Charles Barouch, Moderator [EMAIL PROTECTED] - U2-Users Moderator -- To subscribe to the u2-users or u2-community mailing lists or digest lists, send one or more of the following lines in the BODY (not the subject) of an email addressed to [EMAIL PROTECTED] subscribe u2-users subscribe u2-users-digest subscribe u2-community subscribe u2-community-digest --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. The elapsed time of each test could have been different enough that the differences in the counts would fall within that margin of error. This is particularly noticeable in Tom's test below. Using 'TIME() + some.number' to determine the stopping point could make the first iteration up to .999 seconds shorter than the second. When you're processing hundreds of thousands or millions of iterations per second, that fraction of a second could account for the differences. Using Tom's example below, if the system time was 1.999 at the start, then ETIME for the first pass would be 10005, resulting in 4.001 seconds of processing. The second pass would start around 10005.001 and ETIME would be 10010, resulting in 4.999 seconds of processing. When processing 600,000 iterations, that means a margin of error of 120,000. Hence the results are skewed toward the second loop. To get around this, you could: A) Use SYSTEM(12)(on UD) to get milliseconds or other function to get a more exact measurement of time to make margin of error smaller. B) Add some code at the beginning to ensure TIME() had just incremented to the next number before starting a loop. C) Loop for more than a few seconds to make the partial second a smaller part of the total. D) Loop for a fixed number of times, logging starting and ending times (preferably in milliseconds or smaller). Dean P.S. I apologize for the late post. I'm once again way behind but couldn't resist this one. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:32 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood [EMAIL PROTECTED] wrote on 13 Dec 2004 09:36:42 -0800 I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! ... So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03:CTR = 0 04:ETIME = TIME() + 5 05:LOOP WHILE TIME() ETIME DO 06: CTR += 1 07:REPEAT 08:PRINT While :CTR 09: * 10:CTR = 0 11:ETIME = TIME() + 5 12: 10 CTR += 1 13:IF TIME() ETIME THEN GOTO 10 14:PRINT Go To :CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results (W indicates Winner :-) -- Go To First - -- While First - Go To Count While Count Go To Count While Count --- --- --- --- 769730 W 752380667050 W 458545 655809 734709 W 747373 W 592827 576565 688953 W 785676 W 611628 629807 748265 W 714679 W 564908 The second loop for whatever reason seems to have an advantage. Overall, I suspect there isn't a lot of difference. --Tom Pellitieri Century Equipment --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
It is a silly argument... I just think about utilizing a goto or its facsmile within C++. C, C# (not that I ever did) and it would quickly garner a big red F in school... I don't know of any other language where it would even get beyond a snicker at the unpolished newbie... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 5:27 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. The elapsed time of each test could have been different enough that the differences in the counts would fall within that margin of error. This is particularly noticeable in Tom's test below. Using 'TIME() + some.number' to determine the stopping point could make the first iteration up to .999 seconds shorter than the second. When you're processing hundreds of thousands or millions of iterations per second, that fraction of a second could account for the differences. Using Tom's example below, if the system time was 1.999 at the start, then ETIME for the first pass would be 10005, resulting in 4.001 seconds of processing. The second pass would start around 10005.001 and ETIME would be 10010, resulting in 4.999 seconds of processing. When processing 600,000 iterations, that means a margin of error of 120,000. Hence the results are skewed toward the second loop. To get around this, you could: A) Use SYSTEM(12)(on UD) to get milliseconds or other function to get a more exact measurement of time to make margin of error smaller. B) Add some code at the beginning to ensure TIME() had just incremented to the next number before starting a loop. C) Loop for more than a few seconds to make the partial second a smaller part of the total. D) Loop for a fixed number of times, logging starting and ending times (preferably in milliseconds or smaller). Dean P.S. I apologize for the late post. I'm once again way behind but couldn't resist this one. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:32 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood [EMAIL PROTECTED] wrote on 13 Dec 2004 09:36:42 -0800 I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! ... So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03:CTR = 0 04:ETIME = TIME() + 5 05:LOOP WHILE TIME() ETIME DO 06: CTR += 1 07:REPEAT 08:PRINT While :CTR 09: * 10:CTR = 0 11:ETIME = TIME() + 5 12: 10 CTR += 1 13:IF TIME() ETIME THEN GOTO 10 14:PRINT Go To :CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results (W indicates Winner :-) -- Go To First - -- While First - Go To Count While Count Go To Count While Count --- --- --- --- 769730 W 752380667050 W 458545 655809 734709 W 747373 W 592827 576565 688953 W 785676 W 611628 629807 748265 W 714679 W 564908 The second loop for whatever reason seems to have an advantage. Overall, I suspect there isn't a lot of difference. --Tom Pellitieri Century Equipment --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
Hi Dean, While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. Didn't actually miss that one. It is the reason why I ran my tests 4 times, figuring that the average of the four would be close enough to determine which is fastest (on a stand alone system with me as the only user, and not actually doing any file access, so that catching wouldn't be an issue either, and I ran my tests for 10 seconds to also minimize any fractional seconds impact) And I just did it for the fun of it. I *really* don't care if LOOP/REPEAT or GOTO is faster, I'll always still use loop constructs when the language supports it. btw, you missed a word between of and may. Don't you just hate it when that happens?!!? ;-) Allen --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
On Tue, 28 Dec 2004 19:30:37 -0500, you wrote: It is a silly argument... I just think about utilizing a goto or its facsmile within C++. C, C# (not that I ever did) and it would quickly garner a big red F in school... I don't know of any other language where it would even get beyond a snicker at the unpolished newbie... SNIP That's because the languages you refer to have a higher level of abstraction from the run machine than the ones that you're laughing at. Ever done any FTN, PL1, SPL or assembler programming? -- Allen Egerton [EMAIL PROTECTED] --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
Goo'day, At 19:30 28/12/04 -0500, you wrote: It is a silly argument... I just think about utilizing a goto or its facsmile within C++. C, C# (not that I ever did) and it would quickly garner a big red F in school... Ah! But some of us were programming top down with GO's, JUMP's, what-have-you - quite productively and successfully - long before structured programming was foisted upon an unsuspecting public, and long before schools of any ilk, primary, secondary or tertiary, even knew a skerrick about programming per se. Most of the programming profession in those days, and it's well and truly within my lifetime, were taught their trade by hardware manufacturers. As a matter of small fact, top down programming was preached at me in my early Pick days (late 70's) to overcome frame faulting/ response time problems in MDD boxes with only 32K of memory and up to 8 users Be kind to your elders. I don't know of any other language where it would even get beyond a snicker at the unpolished newbie... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 5:27 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT While quibbling over nanoseconds, some of may have missed a little flaw in your tests that would have nothing to do with caching or memory allocation. The elapsed time of each test could have been different enough that the differences in the counts would fall within that margin of error. This is particularly noticeable in Tom's test below. Using 'TIME() + some.number' to determine the stopping point could make the first iteration up to .999 seconds shorter than the second. When you're processing hundreds of thousands or millions of iterations per second, that fraction of a second could account for the differences. Using Tom's example below, if the system time was 1.999 at the start, then ETIME for the first pass would be 10005, resulting in 4.001 seconds of processing. The second pass would start around 10005.001 and ETIME would be 10010, resulting in 4.999 seconds of processing. When processing 600,000 iterations, that means a margin of error of 120,000. Hence the results are skewed toward the second loop. To get around this, you could: A) Use SYSTEM(12)(on UD) to get milliseconds or other function to get a more exact measurement of time to make margin of error smaller. B) Add some code at the beginning to ensure TIME() had just incremented to the next number before starting a loop. C) Loop for more than a few seconds to make the partial second a smaller part of the total. D) Loop for a fixed number of times, logging starting and ending times (preferably in milliseconds or smaller). Dean P.S. I apologize for the late post. I'm once again way behind but couldn't resist this one. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:32 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood [EMAIL PROTECTED] wrote on 13 Dec 2004 09:36:42 -0800 I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! ... So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03:CTR = 0 04:ETIME = TIME() + 5 05:LOOP WHILE TIME() ETIME DO 06: CTR += 1 07:REPEAT 08:PRINT While :CTR 09: * 10:CTR = 0 11:ETIME = TIME() + 5 12: 10 CTR += 1 13:IF TIME() ETIME THEN GOTO 10 14:PRINT Go To :CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results (W indicates Winner :-) -- Go To First - -- While First - Go To Count While Count Go To Count While Count --- --- --- --- 769730 W 752380667050 W 458545 655809 734709 W 747373 W 592827 576565 688953 W 785676 W 611628 629807 748265 W 714679 W 564908 The second loop for whatever reason seems to have an advantage. Overall, I suspect there isn't a lot of difference. --Tom Pellitieri Century Equipment --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ -- No virus found in this incoming message. Checked by AVG Anti
Re: [U2] LOOP or GOTO on READNEXT
From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 10:33 AM Subject: [U2] LOOP or GOTO on READNEXT 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). snip Loops are loops, they're executed internally with jumps and skips... The LOOP WHILE construct is for the programmer, not for the runtime machine. You really want faster? Create a new file sized appropriately, read the rec from original file, modify the key, write it to the new file. Delete the old file after backing it up, or rename it to keep it available. Oh, and do something to keep new keys from being written to the original file while you're busy copying it, perhaps renaming it as your first step instead of your last one. HTH. --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
In a message dated 13/12/2004 15:49:31 GMT Standard Time, [EMAIL PROTECTED] writes: 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 Religious discussions aside, would it not be wiser to DELETE first and then WRITE, just in case K and NK are the same? Regards Malcolm Bull Remember the websites: + Books training courses for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/index.html_ (http://members.aol.com/_ht_a/mbtraining/index.html) + Our series of MB-Master Self-Tuition Courses for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/mbslist.html_ (http://members.aol.com/_ht_a/mbtraining/mbslist.html) + Our This is ... series of Books for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/thisis.html_ (http://members.aol.com/_ht_a/mbtraining/thisis.html) + PDF versions of our Books MB-Master Self-Tuition courses for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/pdf.html_ (http://members.aol.com/_ht_a/mbtraining/pdf.html) + MB-Cyclopfdia for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtpublish/index.html_ (http://members.aol.com/_ht_a/mbtpublish/index.html) + MB-OnLine Publications for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtexts/index.html_ (http://members.aol.com/_ht_a/mbtexts/index.html) + Our SB+ Reference Pages: _http://members.aol.com/_ht_a/mbtpublish/sbplus.html_ (http://members.aol.com/_ht_a/mbtpublish/sbplus.html) + The general Directory to our Training Consultancy services: _http://members.aol.com/_ht_a/mbtraining/directry.html_ (http://members.aol.com/_ht_a/mbtraining/directry.html) + Request a No-Obligations Quotation for our Training Products Publications: _http://members.aol.com/_ht_a/mbtraining/proform.html_ (http://members.aol.com/_ht_a/mbtraining/proform.html) + Pay for Products or Services with PayPal: _http://members.aol.com/_ht_a/mbtraining/payments.html_ (http://members.aol.com/_ht_a/mbtraining/payments.html) --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
example 2 does not test DONE - why not READNEXT K ELSE EXIT cannot prove it, but I suspect both of these paragraphs would function identically at the object-code level. Rick -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/
Re: [U2] LOOP or GOTO on READNEXT
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/
RE: [U2] LOOP or GOTO on READNEXT
quote who=Rick Ramsey example 2 does not test DONE - why not READNEXT K ELSE EXIT You are quite right. I forgot putting that line in. until DONE do . . . cannot prove it, but I suspect both of these paragraphs would function identically at the object-code level. Rick -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/ -- 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/
RE: [U2] LOOP or GOTO on READNEXT
Hi Karl, Thank you for asking that question, 'cause funny as it sounds I never thought to do a speed test on this construct. I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! LOOP/REPEAT came out at 15.9 Million loops per second while GOTO came out at 14.3 MLPS. This running on a 2.6ghz P4 w2000 install of Unidata PE. (Notice I also prefer the EXIT statement in environments that have it) I actually thought that the GOTO would win, but it appears that the P-code processor has been optimized to work faster with loop constructs. So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) SPEEDTEST.GOTO How long in seconds? ?10 14369777 total loops 1436977.7 per second PC: SPEEDTEST How long in seconds? ?10 15921613 total loops 1592161.3 per second PC: * Release * CUSTOM * SPEEDTEST - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 LOOP COUNTER += 1 IF TIME() GE ENDING THEN EXIT REPEAT PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP * Release * CUSTOM * SPEEDTEST.GOTO - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 10 COUNTER += 1 IF TIME() GE ENDING THEN GOTO 20 GOTO 10 20 PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP Allen E. Elwood Senior Programmer Analyst Sysmark Information Systems, Inc. Direct (818) 361-5251 Fax(818) 361-5251 Cell(818) 359-8162 Home (818) 361-7217 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 07:33 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/
RE: [U2] LOOP or GOTO on READNEXT
I'm not sure of the BASIC SELECT. I've always used it and don't remember ever seeing any adverse affects therefrom. As for the safety option. It might apply somewhere else, but not in this little example. The file contained only about 80 items and a list showed no duplicates either before or after. Plus a list after showed the same number of items. Glad to ask an 'interesting question'. Karl quote who=Derek Falkner 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/ -- 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/
Re: [U2] LOOP or GOTO on READNEXT
quote who=Allen Egerton Loops are loops, they're executed internally with jumps and skips... The LOOP WHILE construct is for the programmer, not for the runtime machine. You really want faster? Create a new file sized appropriately, read the rec from original file, modify the key, write it to the new file. Delete the old file after backing it up, or rename it to keep it available. Why does creating a new file make it faster? Oh, and do something to keep new keys from being written to the original file while you're busy copying it, perhaps renaming it as your first step instead of your last one. New keys are only added by edict from the boss; here and at the client site. Doesn't happen either programatically or automatically. It's a manual only operation on these little files... Okay, I wrote my own program for updating the files. Karl HTH. --- 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/
Re: [U2] LOOP or GOTO on READNEXT
Just checking that you understand the problem with either of these methods. If the key length is already 6 digits then you will end up deleting the record. Richard - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 10:33 AM 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/
Re: [U2] LOOP or GOTO on READNEXT
To further increase your speed with the file copy method use the Overwrite option (O when writing the data back to the cleared desired file from the temp file. This prevents the COPY command from seeing if the record exists and offering up the message. Technically if any target file is cleared, use the (O option in COPY for optimum performance. My 1 cent. - Original Message - From: Allen Egerton [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 10:48 AM Subject: Re: [U2] LOOP or GOTO on READNEXT From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 10:33 AM Subject: [U2] LOOP or GOTO on READNEXT 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). snip Loops are loops, they're executed internally with jumps and skips... The LOOP WHILE construct is for the programmer, not for the runtime machine. You really want faster? Create a new file sized appropriately, read the rec from original file, modify the key, write it to the new file. Delete the old file after backing it up, or rename it to keep it available. Oh, and do something to keep new keys from being written to the original file while you're busy copying it, perhaps renaming it as your first step instead of your last one. HTH. --- 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/
Re: [U2] LOOP or GOTO on READNEXT
quote who=[EMAIL PROTECTED] In a message dated 13/12/2004 15:49:31 GMT Standard Time, [EMAIL PROTECTED] writes: 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 Religious discussions aside, would it not be wiser to DELETE first and then WRITE, just in case K and NK are the same? It probably would be, but I have an aversion to deleting a record without having written it out. In this file it doesn't matter as there aren't that many items. Plus, there's no way the before and after could match. Visually verified that first. Karl Regards Malcolm Bull Remember the websites: + Books training courses for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/index.html_ (http://members.aol.com/_ht_a/mbtraining/index.html) + Our series of MB-Master Self-Tuition Courses for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/mbslist.html_ (http://members.aol.com/_ht_a/mbtraining/mbslist.html) + Our This is ... series of Books for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/thisis.html_ (http://members.aol.com/_ht_a/mbtraining/thisis.html) + PDF versions of our Books MB-Master Self-Tuition courses for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtraining/pdf.html_ (http://members.aol.com/_ht_a/mbtraining/pdf.html) + MB-Cyclopfdia for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtpublish/index.html_ (http://members.aol.com/_ht_a/mbtpublish/index.html) + MB-OnLine Publications for users of Pick MultiValue systems: _http://members.aol.com/_ht_a/mbtexts/index.html_ (http://members.aol.com/_ht_a/mbtexts/index.html) + Our SB+ Reference Pages: _http://members.aol.com/_ht_a/mbtpublish/sbplus.html_ (http://members.aol.com/_ht_a/mbtpublish/sbplus.html) + The general Directory to our Training Consultancy services: _http://members.aol.com/_ht_a/mbtraining/directry.html_ (http://members.aol.com/_ht_a/mbtraining/directry.html) + Request a No-Obligations Quotation for our Training Products Publications: _http://members.aol.com/_ht_a/mbtraining/proform.html_ (http://members.aol.com/_ht_a/mbtraining/proform.html) + Pay for Products or Services with PayPal: _http://members.aol.com/_ht_a/mbtraining/payments.html_ (http://members.aol.com/_ht_a/mbtraining/payments.html) --- 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/
RE: [U2] LOOP or GOTO on READNEXT
Since you have the 2 pieces of code wouldn't the best approach be to benchmark it on the system which is going to run it. Or am I just getting old remembering when we needed to benchmark... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: 13 December 2004 15:33 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/ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
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/
Re: [U2] LOOP or GOTO on READNEXT
Sort of like deleting MV's backwards in an attribute to not miss any. Been there as well. - Original Message - From: Dean Fox [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:04 PM Subject: RE: [U2] LOOP or GOTO on READNEXT 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. 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/ --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] LOOP or GOTO on READNEXT
My understanding of the hashed concept is that once the group is calculated based on normalizing the ID and dividing by the modulo, a binary search occurs through the sorted ID's within the group to locate the real record id. Therefore a collision could only occur if truncation of an ID created an ID that already existed elsewhere. (This is why lists are stored as the ID's of records, rather that the group number and record number within that group.) This could be averted by doing a read of the new ID after truncation and before deleting or writing the record with the new ID, and if it was found to already exist, abort that transaction and issue a warning of collision. Or perhaps I just misunderstood your pointI got the Monday morning blues going on here. *=aee=* -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Dean Fox Sent: Monday, December 13, 2004 11:04 To: '[EMAIL PROTECTED]' Subject: RE: [U2] LOOP or GOTO on READNEXT 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. 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/ --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
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/
RE: [U2] LOOP or GOTO on READNEXT
hmmm..goto wins, but why is your system only doing less than a million loops per second? The slowest I got on my PC was 13 million loops per second, and the fastest was 15.3 MLPS. Also, do you have users actually processing? My system is for me only and therefore is more consistent when testing speed. I agree that the speed really doesn't matter a whole lot. In 10 years we'll all be laughing at how slow our systems were in 2004. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 11:32 To: [EMAIL PROTECTED] Subject: RE: [U2] LOOP or GOTO on READNEXT Allen E. Elwood [EMAIL PROTECTED] wrote on 13 Dec 2004 09:36:42 -0800 I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! ... So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) Ummm... no. Using UniData 6.0 on AIX 5.1 I tested a similar program with a tighter GOTO loop: 01: * Test Loop Speeds 02: * 03:CTR = 0 04:ETIME = TIME() + 5 05:LOOP WHILE TIME() ETIME DO 06: CTR += 1 07:REPEAT 08:PRINT While :CTR 09: * 10:CTR = 0 11:ETIME = TIME() + 5 12: 10 CTR += 1 13:IF TIME() ETIME THEN GOTO 10 14:PRINT Go To :CTR I also wrote a separate program with lines 2-9 above after line 14, so I could test if the order of execution made a difference. I ran each program four times, with the following results (W indicates Winner :-) -- Go To First - -- While First - Go To Count While Count Go To Count While Count --- --- --- --- 769730 W 752380667050 W 458545 655809 734709 W 747373 W 592827 576565 688953 W 785676 W 611628 629807 748265 W 714679 W 564908 The second loop for whatever reason seems to have an advantage. Overall, I suspect there isn't a lot of difference. --Tom Pellitieri Century Equipment --- 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/
Re: [U2] LOOP or GOTO on READNEXT
On Mon, 13 Dec 2004 11:07:38 -0700 (MST), you wrote: snip Why does creating a new file make it faster? Couple reasons. Mostly because you're not deleting the original, which means fewer disk accesses. Remember that until the file's reclaimed, a delete is actually a mark as deleted, not a physical removal. -- Allen Egerton [EMAIL PROTECTED] --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
UD supports LOOP WHILE READNEXT ID DO D3 Supports LOOP READNEXT ID ELSE EXIT UNTIL 0 DO I don't recall what UV supports but it does have a streamlined version without needing the tired EOF=0 or DONE=0 scenarios. My 1 cent. - Original Message - From: Dave Schexnayder [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 11:52 AM Subject: RE: [U2] LOOP or GOTO on READNEXT 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/ --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
Oh please God no -- Debster -- Original message -- On Mon, 13 Dec 2004 11:07:38 -0700 (MST), you wrote: Why does creating a new file make it faster? Couple reasons. Mostly because you're not deleting the original, which means fewer disk accesses. Remember that until the file's reclaimed, a delete is actually a mark as deleted, not a physical removal. -- Allen Egerton [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/
Re: [U2] LOOP or GOTO on READNEXT
What you may be missing is how to selects differ. The 'EXECUTE SELECT' selects the complete file before processing starts. The 'SELECT file.var' selects one group at a time and processes that group. If a Key changes it may get written to a different group. If that group is after the original group then the basic select will find it again when it gets to that group. In your example, when it found the Key the second time the Key would already be 6 digits so it would not change, Old Key = New Key. You would then write it with New Key and immediately delete it with Old Key. No more record. Richard - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 3:10 PM 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
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
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/
RE: [U2] LOOP or GOTO on READNEXT
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/
Re: [U2] LOOP or GOTO on READNEXT
Be careful of consecutive speed tests. With memory caching and virtual memory, the second process benefits from the first process loading and/or leaving data in memory. That may invalidate your victory if the second test won. My 1 cent. P.S. The GOTO Holy war will never end until it's removed from the compiler and that ain't gonna happen. - Original Message - From: Allen E. Elwood [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 12:36 PM Subject: RE: [U2] LOOP or GOTO on READNEXT Hi Karl, Thank you for asking that question, 'cause funny as it sounds I never thought to do a speed test on this construct. I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! LOOP/REPEAT came out at 15.9 Million loops per second while GOTO came out at 14.3 MLPS. This running on a 2.6ghz P4 w2000 install of Unidata PE. (Notice I also prefer the EXIT statement in environments that have it) I actually thought that the GOTO would win, but it appears that the P-code processor has been optimized to work faster with loop constructs. So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) SPEEDTEST.GOTO How long in seconds? ?10 14369777 total loops 1436977.7 per second PC: SPEEDTEST How long in seconds? ?10 15921613 total loops 1592161.3 per second PC: * Release * CUSTOM * SPEEDTEST - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 LOOP COUNTER += 1 IF TIME() GE ENDING THEN EXIT REPEAT PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP * Release * CUSTOM * SPEEDTEST.GOTO - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 10 COUNTER += 1 IF TIME() GE ENDING THEN GOTO 20 GOTO 10 20 PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP Allen E. Elwood Senior Programmer Analyst Sysmark Information Systems, Inc. Direct (818) 361-5251 Fax(818) 361-5251 Cell(818) 359-8162 Home (818) 361-7217 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 07:33 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/
RE: [U2] LOOP or GOTO on READNEXT
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. 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/
RE: [U2] LOOP or GOTO on READNEXT
UPDATE filename SET @ID = EVAL FMT(@ID,'R%6'); Poetry, Poetry. --- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] LOOP or GOTO on READNEXT
Fair enough. My earlier speed tests (circa R80 and MCD) were much longer and the virtual memory did its job and invalidated the tests. Nowadays we're splitting the atom so finely that 1/13,000,000 of a second is just barely longer than 1/14,000,000. Speaking of splitting, didja hear of the guy who ordered a pizza and asked to have it cut in 6 slices cause he didn't think he could eat 8? Mark - Original Message - From: Allen E. Elwood [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 2:30 PM Subject: RE: [U2] LOOP or GOTO on READNEXT Hi Mark! No, I don't suspect that the GOTO holy war will ever end. It will just LOOP/REPEAT forever!! LOLsorry I really cracked myself up on that one. Yes, when reading and writing records to a file, the O/S will eventually load the entire file into main memory if there is enough room. However, there are no read or write statements in the program, and therefore nothing to stick into main memory in the first place. Also, since the real program that is running is Unidata, and just using the compiled P-code as a template of sorts, my program has to be read completely before execution can begin, so no read/write benefits could occur from that standpoint, since the INPUT statement has to be executed before the speedtest begins. But I ran them again in reverse order just to be uber-sure and they had the similar results, although both of the runs suffered about a 1 million loop per second decrease as I have a lot more windows open now. Allen -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Mark Johnson Sent: Monday, December 13, 2004 10:35 To: [EMAIL PROTECTED] Subject: Re: [U2] LOOP or GOTO on READNEXT Be careful of consecutive speed tests. With memory caching and virtual memory, the second process benefits from the first process loading and/or leaving data in memory. That may invalidate your victory if the second test won. My 1 cent. P.S. The GOTO Holy war will never end until it's removed from the compiler and that ain't gonna happen. - Original Message - From: Allen E. Elwood [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 12:36 PM Subject: RE: [U2] LOOP or GOTO on READNEXT Hi Karl, Thank you for asking that question, 'cause funny as it sounds I never thought to do a speed test on this construct. I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! LOOP/REPEAT came out at 15.9 Million loops per second while GOTO came out at 14.3 MLPS. This running on a 2.6ghz P4 w2000 install of Unidata PE. (Notice I also prefer the EXIT statement in environments that have it) I actually thought that the GOTO would win, but it appears that the P-code processor has been optimized to work faster with loop constructs. So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) SPEEDTEST.GOTO How long in seconds? ?10 14369777 total loops 1436977.7 per second PC: SPEEDTEST How long in seconds? ?10 15921613 total loops 1592161.3 per second PC: * Release * CUSTOM * SPEEDTEST - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 LOOP COUNTER += 1 IF TIME() GE ENDING THEN EXIT REPEAT PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP * Release * CUSTOM * SPEEDTEST.GOTO - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 10 COUNTER += 1 IF TIME() GE ENDING THEN GOTO 20 GOTO 10 20 PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP Allen E. Elwood Senior Programmer Analyst Sysmark Information Systems, Inc. Direct (818) 361-5251 Fax(818) 361-5251 Cell(818) 359-8162 Home (818) 361-7217 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 07:33 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
RE: [U2] LOOP or GOTO on READNEXT
Hi Mark! No, I don't suspect that the GOTO holy war will ever end. It will just LOOP/REPEAT forever!! LOLsorry I really cracked myself up on that one. Yes, when reading and writing records to a file, the O/S will eventually load the entire file into main memory if there is enough room. However, there are no read or write statements in the program, and therefore nothing to stick into main memory in the first place. Also, since the real program that is running is Unidata, and just using the compiled P-code as a template of sorts, my program has to be read completely before execution can begin, so no read/write benefits could occur from that standpoint, since the INPUT statement has to be executed before the speedtest begins. But I ran them again in reverse order just to be uber-sure and they had the similar results, although both of the runs suffered about a 1 million loop per second decrease as I have a lot more windows open now. Allen -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Mark Johnson Sent: Monday, December 13, 2004 10:35 To: [EMAIL PROTECTED] Subject: Re: [U2] LOOP or GOTO on READNEXT Be careful of consecutive speed tests. With memory caching and virtual memory, the second process benefits from the first process loading and/or leaving data in memory. That may invalidate your victory if the second test won. My 1 cent. P.S. The GOTO Holy war will never end until it's removed from the compiler and that ain't gonna happen. - Original Message - From: Allen E. Elwood [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 13, 2004 12:36 PM Subject: RE: [U2] LOOP or GOTO on READNEXT Hi Karl, Thank you for asking that question, 'cause funny as it sounds I never thought to do a speed test on this construct. I didn't include the delete statement because what you really wanted to test was the LOOP/REPEAT vs. the GO construct. Guess what? After doing four consecutive runs and picking the fastest of each four, LOOP/REPEAT wins!! LOOP/REPEAT came out at 15.9 Million loops per second while GOTO came out at 14.3 MLPS. This running on a 2.6ghz P4 w2000 install of Unidata PE. (Notice I also prefer the EXIT statement in environments that have it) I actually thought that the GOTO would win, but it appears that the P-code processor has been optimized to work faster with loop constructs. So does this end the GOTO holy war? Less Filling, Tastes Better, Goes Faster??? ;-) SPEEDTEST.GOTO How long in seconds? ?10 14369777 total loops 1436977.7 per second PC: SPEEDTEST How long in seconds? ?10 15921613 total loops 1592161.3 per second PC: * Release * CUSTOM * SPEEDTEST - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 LOOP COUNTER += 1 IF TIME() GE ENDING THEN EXIT REPEAT PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP * Release * CUSTOM * SPEEDTEST.GOTO - does what it sounds like PRINT 'How long in seconds? ':;INPUT HL START = TIME() ENDING = START + HL COUNTER = 0 10 COUNTER += 1 IF TIME() GE ENDING THEN GOTO 20 GOTO 10 20 PRINT COUNTER:' total loops' PRINT COUNTER/HL:' per second' STOP Allen E. Elwood Senior Programmer Analyst Sysmark Information Systems, Inc. Direct (818) 361-5251 Fax(818) 361-5251 Cell(818) 359-8162 Home (818) 361-7217 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, December 13, 2004 07:33 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
RE: [U2] LOOP or GOTO on READNEXT
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
Re: [U2] LOOP or GOTO on READNEXT
quote who=Mark Johnson 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. I don't know the answer, but as the original poster of the question, I have just a bit of history: I started on PICK native machines, which were upgraded to AIX boxes running uniVerse shortly thereafter (UV5.3) and learned how to program better on that platform. I'm not a programmer; I use programming to solve problems. Just a bit different way of looking at the world, IMO. The point? I remember figuring out at one release of UV (don't remember which; 6.N? 7.N) that I could use SINGLE QUOTES instead of DOUBLE QUOTES when doing: OPEN '','FILE' . . . rather than OPEN ,FILE . . . That saved me at least one keypress per quote... KLP 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/ -- 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/
RE: [U2] LOOP or GOTO on READNEXT
quote who=Bob Witney Since you have the 2 pieces of code wouldn't the best approach be to benchmark it on the system which is going to run it. Or am I just getting old remembering when we needed to benchmark... BenchmarK? We can do that? You must live in a dream world... I guess I ought to give that a try, when my priority list gets under about 2000 items. KLP (it would get down faster if y'all would quit posting to this list. I just have to read a bunch of them. Great help found here!) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: 13 December 2004 15:33 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/ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ --- 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/
RE: [U2] LOOP or GOTO on READNEXT
Your explanation finally sunk in. Thanks to the others who tried. My file was static with no updating possible, or at least likely. That would show the same items regardless of the select methodology. That's one lesson I've been lucky not to have learned the hard way. Thanks, Karl quote who=Derek Falkner 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