Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Dimension to resize an array
Message
From
10/01/2006 18:23:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01085313
Message ID:
01085448
Views:
17
>I am seeing something strange when trying to resize an array.
>
>I have an array that has, say 10 rows and 5 columns (aMyArray[10,5])
>
>I want to add a column (and later assign a value to it). Here is what I do:
>
>
>dimension aMyArray( alen(aMyArray,1), alen(aMyArray,2)+1 )
>
>
>I expected that there will be a 6th column with value .F. in every row. But, instead, all .F.-value elements go to the bottom of the array.
>
>What am I missing?
>
>Thank you.

As explained in other replies you got, the array is, unfortunately, treated as a one-dimensional structure; the two dimensions are just a convenient way to access it. But in the case of redimensioning, you are in trouble.

Some options:

  • Give the array sufficient columns in the first place.
  • To redimension, copy to another array (yech!).
  • Use my "large array" class from the download section, instead of normal arrays. Accessing the array elements is slower than with built-in arrays, but redimensioning is no problem. Also, you can have more than 2 dimensions in your array.
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Previous
    Next
    Reply
    Map
    View

    Click here to load this message in the networking platform