Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Invalid subscript reference
Message
De
02/12/2006 09:37:03
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
02/12/2006 02:37:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01173721
Message ID:
01174377
Vues:
10
>>>Looks like I've been wasting odd lines of code for years then.
>>>
>>>I could have *sworn* I've used that lazy way out in the odd noddy code I've written in the past. Let me see now ... was it in PLM/86?
>>>
>>>Mind you, for readability, I'd still rather see something more meaningful, like:
>>>
>>>lnNumFiles = ALEN(laFiles,1)
>>>
>>>For I = 1 to lnNumFiles ...
>>
>>I do that, but not for readability. I do it because each time I don't, there comes a case when I need that value elsewhere in the code, and I don't want to call alen() multiple times.
>
>Why ?

Because I usually need the array's size at the time - it's often a result of some VFP function which creates an array, so I want to keep information on how many rows were found. The code may later redimension the array, and alen() would give a different result. In that case, I prefer having another variable to hold the new array size, so I know which is which without misreading the code.

Speed is a minor issue here - alen() is only a few milliseconds slower than retrieving a value of a variable, so calling it again doesn't cost much at all. Still, it's an old habit of mine - if it's a function, don't call it twice if you don't have to.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform