Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Collection through another property
Message
From
12/08/2003 10:53:00
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00819334
Message ID:
00819374
Views:
11
It's ok, it looks like a problem elsewhere that's causing this, as it works fine if I knock up a simple class.

Thanks for your help.

Kev

>Are you able to use the GetKey method explicitly to get the index value? What value are you passing in and are you sure it exists in your collection? Note: Index keys are case sensitive.
>
>>>>Hi
>>>>
>>>>I need to access the Item in a collection via another property's access method but it doesn't like it at all:
>>>>
>>>>
?this.Item(1) && Fails
>>>>
>>>>Because I have to specify the () it thinks I'm trying to access an array and errors, I need to use an Access Method in the property to return the Item, but it doesn't work.
>>>>
>>>>Any ideas?
>>>>
>>>>Thanks
>>>
>>>Kev,
>>>If the property you were trying to access was an array property, this access should should work. The index would be passed to the Access method and you could use that index to get the correct item in the collection.
>>>
>>>HTH.
>>
>>Larry
>>
>>Thanks, I did actually try that (but wanted confirmation), now that you've suggested it, I have a problem doing it this way, and I think this may be down to the fact the property is an array, as you know Items in a collection can be accessed via their Key or the index, so I wrote the following:
>>
*-------------------------------------------------------------
>>*Method	: Item_Access
>>*Author	: Kevin Lawrence
>>*Date	: 12/08/2003
>>*-------------------------------------------------------------
>>*Desc	: Return Item from the List Collection (only accepts int)
>>*-------------------------------------------------------------
>>LPARAMETERS tuIndex
>>LOCAL lnIndex AS Integer
>>lnIndex = tuIndex
>>
>>*Get Key if character
>>IF TYPE("tuIndex") = "C"
>>	lnIndex = this.List.GetKey(tuIndex)
>>ENDIF
>>
>>*Ensure Key exists
>>IF lnIndex > 0 AND this.List.Count > 0
>>	RETURN this.List.Item(lnIndex)
>>ENDIF
>>
>>But this.List.GetKey(tuIndex) returns 0 and I can't get this to work unless I specifiy the index, but I need to specify the Key too.
>>
>>Any ideas, should be easy to replicate.
>>
>>Thanks
>>Kev
Previous
Reply
Map
View

Click here to load this message in the networking platform