Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array Dimensions - Confusing VFP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00687552
Message ID:
00687921
Vues:
31
>Thanks for the Answer...
>I can determine if I have a ONE or Two dimensional Array with this
>
>llTwoDimensions = alen(MyArray)#alen(MyArray,1)
>
>my problem was this:
>
>for i=1 to alen(MyArray,1)
>?MyArray(i,1) &&This always delivered the first value of 1 Dimensional Arrays
>endfor
>
>I think it still is a Bug if I get no error for this:
>
>dimension myArray(3)
>myArray(1)=1
>myArray(2)=2
>myArray(3)=3
>
>?myArray(3,1) &&Should at least give me an error but NOT the value 1
>?myArray(3,2) &&Should at least give me an error but NOT the value 2
>
>*Because Foxpro seems to use
>*myArray(1,1)=1,myArray(1,2)=2,myArray(1,3)=3
>*myArray(2,1)=1,myArray(2,2)=2,myArray(2,3)=3
>*myArray(3,1)=1,myArray(3,2)=2,myArray(3,3)=3
>*But why does alen(myArray) give me 3 then?
>?myArray(999999,3) Even gives me 3... I don't understand that.

This sort of behavior goes back at least as far as 2.x. Consider the following
DIMENSION a_foo[2]
? ALEN(a_foo, 2) && Returns zero
DIMENSION a_foo[2, 1]
? ALEN(a_foo, 2) && Returns one
This is probably the fundamental reason why you see the behavior you do. As a result
? ALEN(a_foo, 2) < 2
will also tell you whether or not you have a one or two dimensional array. If it's one dimension, you simply need one subscript. If it's two, you need two.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform