Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I can't use Collection with case insensitive serach of key!
Message
De
25/06/2004 04:49:30
Emanuele Bonin
EB Soluzioni Informatiche
Tezze S/B, Italie
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
I can't use Collection with case insensitive serach of key!
Divers
Thread ID:
00917124
Message ID:
00917124
Vues:
57
Hi All
below there is a code similar to the code that i use to store variuos information on al collection of objects.

I can't subscribe add event and change the inserted Key of collection item to UPPER, so i have decide t subscribe item event to perform an insensitive search of the passed key ..... but even if i subscribed Item event, when i try to pass a Key that haven't correct case, the collection emit an error.

There is some way to perform my goal or is a dream ?

Thanx in advance
---------------------------------------------------
Local oColl
oColl = CreateObject('Mycollection')

oColl.Add("Goffy", "Key1")

Activate Screen
Clear
? oColl.Item("Key1").name && OK
? oColl.Item("KEY1").name && Error ... even if i overwrite Item Event 8(((((

Return

Define Class Mycollection As Collection
   NumOfItems = 0
   Function Init() 
      This.AddProperty('objects[1]', '')
       
   EndFunc
   
   Function Add(eItem, cKey, eBefore, eAfter)
      This.NumOfItems = This.NumOfItems + 1

      Dimension This.objects(This.NumOfItems, 2)

      This.Objects[This.NumOfItems, 1] = cKey
      This.Objects[This.NumOfItems, 2] = CreateObject('Empty')

      AddProperty(This.Objects[This.NumOfItems, 2], 'Key',      cKey)
      AddProperty(This.Objects[This.NumOfItems, 2], 'Name',      eItem) 
   EndFunc

   Function Item(eIndex)
      If Vartype(eIndex) = 'C'
         Local eIndex
         eIndex = Ascan(This.Objects, eIndex, 1, -1, 1, 15) && ASCAN with case Insensitive
         If !Empty(eIndex)
            Return This.Objects[eIndex, 2]
         Else
            Return DoDefault(eIndex)
         Endif   
      Else
         Return This.Objects[eIndex, 2]
      Endif   
   Return   
EndDef
bye, Emanuele!
In the beginning the Universe was created.
This has made a lot of people very angry and been widely regarded as a bad move.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform