Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing object array
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01668317
Message ID:
01668325
Vues:
68
Rick,

I'm still confused as to what I'm seeing even after understanding what you said about the addproperty using the literal string to declare the array. I understand and have fixed my code.

But, try this new code and the array that is passed in the object does not contain the second array element - only one element which is 'Rick'.

Try my fixed code that is slightly enhanced that tries to access the 2nd element of the passed array and it isn't found and crashes with 'Array dimensions are invalid'.

Also, see my variable lnElementCount in the CallMethod and the value is always 1. I guess I'm not seeing the entire array being passed - just the first element.

***************************************************
***************************************************
Yes, FoxPro arrays are a nightmare!!!
***************************************************
***************************************************
local x
declare laItems[2]

laItems[1] = "Rick"
laItems[2] = "Markus"

loObj = CREATE("Empty")
ADDPROPERTY(loObj,"aItems[1]",laItems)
SET STEP ON
x = CallMethod(loObj,1)
*x is 'Rick'
?x

loObj = .null.
release loObj
loObj = CREATE("Empty")
ADDPROPERTY(loObj,"aItems[1]",laItems)
SET STEP ON
x = CallMethod(loObj,2)
*x should be 'Markus', but it crashes in CallMethod
?x


RETURN

FUNCTION CallMethod(loObj,tnElementNo)
local x as Object,lnElementCount
local loEx as Exception
local lcMsg
lnElementCount = alen(loObj.aItems,1)
?lnElementCount
try
x = loObj.aItems[tnElementNo]
?x
catch to loEx
lcMsg = loEx.Message
?lcMsg
endtry

return x
*return loObj.aItems[1]
ENDFUNC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform