Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ideas for passing records back to calling form
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01624724
Message ID:
01628009
Vues:
64
Hi Hugo.

Thanks for responding. The problem is, I don't have a key for the first few items added to the collection.

The reason for this is that the collection holds "options chosen" by the user on the screen - but it starts off with me passing into the screen a couple of "preconfigured" options (say, 2 or 3) that are marked "required" i.e. the user has to fill in something for them (e.g. a date range etc). But then there are 20 or so other options on the screen which are not required and so I do not preconfigure them - when the user is done, if they filled in something for one of the options, that is added to the collection when the screen is exited.

Why I wanted it sorted is that the resulting group of options also prints out it's criteria at the bottom of the report - and it makes sense to the user if the options print in the order that they appeared on the screen (because otherwise, it sort of looks random). So what I was wanting to do was to sort the collection by the .TabIndex of each on-screen control. And this would have worked if I could somehow have updated the index key for the couple of objects passed in (they are put into the collection before the form is loaded - so I don't have a .TabIndex yet to work with).

If I could have updated the key for all the members in the collection, that would have worked. But I can't so I end up re-creating the collection after sorting it. I guess I could re-create the collection before the form is closed and at that time look up the .TabIndex of each object - but would that be faster than what I am doing? And is there any performance hit from traversing a collection using a key?

Albert


>>Hi Tamar,
>>
>>Am liking working with collections! Paper was also helpful.
>>
>>One thing I ran into that I could not solve was that I wanted to sort the collection after it had been assembled - I looked at putting an index key with each item in the collection but unfortunately in this situation, I do not know the key until after the collection has been created (it is a collection of objects and the key that I could use comes at a later stage in the process).
>>
>>It seems there is no way to update a key after the fact so what I had to do was to throw all the objects into an array, put my key into the 2nd column of the array, sort the array and then move the objects back into a new collection. It works but doesn't seem optimal. Thankfully it will only ever be a small collection of 20 to 30 objects. I don't really notice any big hit on performance.
>>
>>Albert
>
>Did you take a look at the eBefore and eAfter parameters of the Add method?
>
>for example:
>
>
>loCollection	= createobject('Collection')
>loCollection.Add('abc', '_123')
>? loCollection.Item(1)  && abc
>
>loCollection.Add('def', '_345', '_123')
>
>? loCollection.Item(1) && def
>? loCollection.Item(2) && abc
>
>
>Another property that might help you is KeySort 0 - by index, 1 - by index desc, 2 - by key, 3 - by key desc
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform