>Try the following:
>
>PUBLIC aPubArray[2,3]
>aPubArray = 'Foo'
>PRIVATE aPrivArray[2,3]
The previous statement only hides any aPrivArray variable from a higher level. PRIVATE doesn't allocate the array and, after the above statement, the aPrivArray doesn't exist yet.
>aPrivArray = 'Bar'
Now, aPrivArray becomes a char string variable, not array.
>? DEMOARRAYERROR(@aPrivArray) && OK
>? DEMOARRAYERROR(@aPubArray) && meltdown
>
>FUNCTION DEMOARRAYERROR
>LPARAMETER aRefArray
>DIMENSION aRefArray[4,2]
Being a test program, it's not correct to reDIMENSION the parameter. This will make it to be array anyway! And this is what changes the results of your test.
Try the following:
PUBLIC aPubArray[2,3]
aPubArray = 'Foo'
PRIVATE aPrivArray
DIMENSION aPrivArray[2,3]
aPrivArray = 'Bar'
?"Call with private array:"
= DEMOARRAYERROR(@aPrivArray) && OK
?"Call with public array:"
= DEMOARRAYERROR(@aPubArray) && meltdown
FUNCTION DEMOARRAYERROR
PARAMETER aRefArray
?"Array length:", alen(aRefArray)
? aRefArray[1,1]
RETURN
This works just fine, with both PRIVATE and PUBLIC arrays.
Vlad
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement