Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Collection through another property
Message
From
13/08/2003 04:12:08
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00819334
Message ID:
00819709
Views:
11
LArry

Further to the last message I sent you, I have an update. When I access the Item property from outside the COM Object the Character I pass to the property contains a CHR(0) at the end of the character string, making the value illegal!!!!

Now I'm completely lost, sounds like something strange with COM is happening, as it only happens when I access it outside the COM Object.

Obviously the short-term solution is to check the passed property and see if it has a CHR(0) at then end and then remove it, but I wouldn't mind knowning what this (bug?) is?

Thanks
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