Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Argument starter - The roots of all evil
Message
De
07/09/2004 04:55:58
 
 
À
06/09/2004 23:15:11
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00938079
Message ID:
00939882
Vues:
42
Dragan

>The offending code may need general refactoring, if it's so old. I figure the author used the tecniques known at the time and probably painted himself (ahem, themselves?) in the corner where Loop/Exit seemed simpler than alternatives.

No chance of that. I'm overdue to completely rewrite the whole system, from scratch, in VFP. The author learnt to program but not to structure, like I had the benefit of in college.

>At that time (1989) I got introduced to Fox, and there were a few things that I hated - namely, that you could (had to!) use strings without quotation marks in a bunch of places, like in use command, and that it didn't have a Repeat/Until loop.

Yeah, Repeat ... Until would be nice. The original dBASE III+, by which I learnt xBASE (back in 85), noticeably didn't have one, and I was used to it in, say, Pascal, but I've got on without it all these years and haven't missed it, or thought "that would have been a R ... U candidate". Most of my contructs are with these basic building blocks. Sometimes I'm not even aware of new features, in 7!, until I read about them on the UT!!!

>If your principle turns a four-liner into a dozen-liner, I'd probably not feel tempted to fix it if it was in some code I'd have to work over, but I'd surely frown.

My principles don't go that far. See the soln. to your test below.

>
>That's what I usually do. The emphasis here was on heavy, when the conditions are numerous and would lead to a long sausage of nested IFs, and when the meat of the process is... well, full of tendons and bones, i.e. when the extra level of indentation (even with my tabs set to 3) would just make it hard to follow.

Surely you'd use a CASE statement though?

>Come to think of it, I'm not writing such code myself. It's in inherited code I got from others, where I'm happy to leave early bailouts as they are, and where I don't even suggest to rework it. You see, I've already seen what it does, and I know how it works, and I know that it works. So I don't see a reason to change it, not in that part.

Yeah, but if you've seen the code that I posted, it's not very easy to debug.

>Code follows:
>
For i=1 to Alen(this.alist,1)
>	lcValue=prof_r(This.cSection,"row"+Transform(i),"","C")
>	If Empty(lcValue)
>		Exit
>	Else
>		this.alist(i)=lcValue
>	EndIf
>EndFor
>The Prof_r function reads profile string. Now how would you do this one without making it less simple?

First I'd store ALEN() in a var, to save reevaluating it every time thro' the loop :), so you can't count that line. If you don't count the Do while loop as 2 lines then I achieve the same with just 1 extra line:

>
lnLen = ALEN( this.aList, 1)
I = 1
Do while For I <= lnLen ;
   and not EMPTY( lcValue)
	lcValue = prof_r( This.cSection, "row"+Transform( I), "", "C")
	If not Empty( lcValue)
		this.alist( I) = lcValue
         Else
                   I = I + 1
	EndIf
EndDo
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform