Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Array : Dimension vs Ains
Message
From
01/02/2000 12:56:49
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00325376
Message ID:
00325689
Views:
25
>>>>To add another row to a two column array, is it more proper to redimension or use ains? Under what circumstance would you want to use ains() and what dangers are there in using it to add rows given that it does not change its size?
>>>>
>>>
>>>AINS() does not redimension the array; it pushes the last row off the edge of the world into an abyss. Read the remarks at the end of the VFP Help on AINS()
>>>
>>>DIMENSION would be used to resize the array, and then AINS() to shove things in at the middle.
>>
>>AINS() will move things down (if the array is re-dimensioned first) ONLY if the array is single dimensioned. If it multi-dimensioned, it "loses" the data when you try to insert a column.
>
>Adding columns always is a lossy maneuver in VFP; this is an issue not with AINS() but with VFP's adjustment of the aray by adding new elements to the end of the array when you expand, and then rearranging the data exactly as if it were a 1 dimensional array. Things get frobbed because rather than adding a new element to each row, all the new elements are at the end.
>
>The behavior of AINS() is consistent - it inserts a row and pushes the last row off. It does this in the same way that adding n elements with AINS() pushes the last n entries off the bottom of the pile.
>
>Adding columns is squirrely - blame the right thing for the evil effects on your data!

Though it may be round-about I prefer VFP's table handling capabilities to it's array handling capabilities. For example, if I wanted to add a column to an array, I would append the array into a cursor, add the column (field) to the cursor then copy the cursor out to an array of the same name. I told you it was round-about but at least I get what I expect.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform