Drew Wutka
DWUTKA at Marlow.com
Thu Jun 25 10:51:50 CDT 2009
So convoluted loops are easier to follow then clear language labels? Otay.... Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Wednesday, June 24, 2009 5:58 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Learning .Net -- PHP Instead? Neither of your examples were easy to follow. It took me some time to work out what they were doing. Mainly because they do not do the same thing. I assume you want to implement the second version. That is: Do Step 1 If Not <Some Condition> then Do Step2 If <Another Condition> then Step 3 Exit Do End If Loop If <Final Condition> then Step 4 Exit Do End if End if Loop or if you don't like using Exit Do, use flags: flg4OK = False Do Step 1 If Not <Some Condition> then flg3OK = False Do Step2 If <Another Condition> then Step 3 flg3OK = True End If Loop Until flg3OK If <Final Condition> then Step 4 flg4OK = True End if End if Loop Until flg4OK -- Stuart On 24 Jun 2009 at 17:15, Drew Wutka wrote: > I am going to replace 'a bunch of code' with Step X. > > Which is easier to follow?: > > Step 1 > If SomeCondition Then > Step 2 > Else > Step 1 > Step 2 > End if > If Another Contition Then > Step 3 > Else > Step 2 > Step 3 > End if > If FinalCondition Then > Step 4 > Else > Step 1 > Step 2 > Step 3 > Step 4 > End if > > OR > > Step1: > Step 1 > If SomeCondition Then Goto Step1 > Step2: > Step 2 > If Not Another Condition Then Goto Step2 > Step3: > Step 3 > If Not FinalCondition Then Goto Step1 > Step4: > Step 4 > > Which is cleaner? The first method could have you repeating code over > and over, the second method has the code once, and simple (and what > should be well labeled) 'jump points' to make complex 'logic' simpler. > > Drew > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart > McLachlan > Sent: Wednesday, June 24, 2009 4:47 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] Learning .Net -- PHP Instead? > > What's wrong with > > Do > ... initial code here.... > If <condition1> then 'else goto loop > ...more code here.... > If <condition2> then 'else goto loop > ...more code here... > End If > End if > Loop > > Again, the indentation from the IF...End IF makes the code much easier > to follow that a flat > sequence with a series of GOTOs hidden throughout. > > > -- > Stuart > > On 24 Jun 2009 at 13:54, Drew Wutka wrote: > > > A Do Loop cannot have extra 'loop' statements. > > > > Ie: > > > > Do > > > > 'some condition is met: then Loop > > > > Loop > > > > Can't do that. You can do that with a Goto statement. > > > > Drew > > > > -----Original Message----- > > From: accessd-bounces at databaseadvisors.com > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte > > Foust > > Sent: Wednesday, June 24, 2009 11:52 AM > > To: Access Developers discussion and problem solving > > Subject: Re: [AccessD] Learning .Net -- PHP Instead? > > > > A Do...Loop would be preferable to Goto. > > > > Charlotte > > > > -----Original Message----- > > From: accessd-bounces at databaseadvisors.com > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka > > Sent: Wednesday, June 24, 2009 8:27 AM > > To: Access Developers discussion and problem solving > > Subject: Re: [AccessD] Learning .Net -- PHP Instead? > > > > I think it should be said that you shouldn't use GOTO to prevent > > breaking your code into more logical parts. Errorhandling is a > > situation which would allow Goto then. There is another situation. > > Let's use an imaginary 'Phone' object that is going to make a call, > and > > it needs to try 20 times unless successful: > > > > Dim obj as Phone > > Dim intTries as Long > > Dim blFailed as Boolean > > intTries=0 > > Set obj=New Phone > > > > StartOfCall: > > > > blFailed=True > > intTries=intTries+1 > > If intTries=21 then Goto > > > > The information contained in this transmission is intended only for > the person or entity > > to which it is addressed and may contain II-VI Proprietary and/or > II-VI Business > > Sensitive material. If you are not the intended recipient, please > contact the sender > > immediately and destroy the material in its entirety, whether > electronic or hard copy. > > You are notified that any review, retransmission, copying, disclosure, > dissemination, > > or other use of, or taking of any action in reliance upon this > information by persons > > or entities other than the intended recipient is prohibited. > > > > > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > The information contained in this transmission is intended only for the person or entity > to which it is addressed and may contain II-VI Proprietary and/or II-VI Business > Sensitive material. If you are not the intended recipient, please contact the sender > immediately and destroy the material in its entirety, whether electronic or hard copy. > You are notified that any review, retransmission, copying, disclosure, dissemination, > or other use of, or taking of any action in reliance upon this information by persons > or entities other than the intended recipient is prohibited. > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.