Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Many variables vs array
Message
De
15/11/2020 16:44:00
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:
01677141
Message ID:
01677166
Vues:
60
>As I am sure you know that VFP allows at least 10 ways to get any job done :)
>I got a good input on my question and now ready to move on to the next topic :)

Traditionally, the number was three, probably because of the previous traditions (with 1, 3, 7, 12 base). "If it can't be done three ways in fox, then a) it can't be done at all, b) isn't worth doing".

I wanted to suggest a collection myself, for convenience. While slower than an array, it would save time
- property search time on app object, as it wouldn't grow by 50 properties for this one purpose
- your coding time when dealing with the array - you'd have to store the indices of your array elements, or give them names in a separate column... making it look like a narrow lookup table or a bunch of key-value pairs, again better suited to a cursor (and cursor could be read from a text file, so you'd be able to keep it outside the exe and adjust as needed without a build...)
- these names would be property names, but they'd have to be prefixed somehow, to separate them from other properties to avoid duplicate names and/or confusion, adding to your coding time

Since it's a key-value bunch of things, collection is what you need, and that collection can be a member of your app object. You can still
- address each element by its key
- fill the whole thing from a text file (in a simple loop, just filetostr(), aLines() then chop each row into key and value (i.e. sql snippet) and add to the collection
- have short enough keys, or of arbitrary length, without mixing them up with anything else in your app object
- add them on the fly, if needed (which you could have done with individual properties or the array, though)
- remove them somewhat easier than the solo properties or array elements

You do lose some speed, but that's marginal, compared with the time you spent with us, discussing this :).

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
Répondre
Fil
Voir

Click here to load this message in the networking platform