Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ains() bug
Message
From
31/01/2019 07:58:16
 
 
To
31/01/2019 03:57:43
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Database:
MS SQL Server
Miscellaneous
Thread ID:
01665830
Message ID:
01665842
Views:
61
The solution I use is
* get files
n=ADIR(a,"*.prg")
* allocate space a new column
DIMENSION a[n,6]
* insert new column on the end
=AINS(a,6,2)
The result will be an array with six columns with the last column being .F., and ready for data. The trick is the AINS().

>>This code
>>
n=adir(a,"*.prg")
>>DIMENSION a(n,6)
>>ains(a, 2,2)
>>LIST MEMORY like a
>>doesn't work as expected, the array ends up a mess. Only the first row has a cell inserted at 2nd column, the rest not quite so. However, it works properly in Chen's VFPA. Can't find it documented on his documentation page, so reporting it here.
>
>Whoa, a whole discussion around this bit.
>
>Martina: DIMENSION a(n,6) destroy data in array.
>
>Nope, it doesn't destroy anything. It adds enough elements to the end of the array to make a total of n*6 elements, and the added elements are initialized to .f., as documented. The shortcoming of Fox from day one was that it doesn't rearrange elements as per dimension change - it treats it as an one-dimensional array internally. The rows don't shift to accomodate new elements at the end of each row, because the new elements aren't added there. So now a(3,1) is not the 11th element anymore, it's the 13th, and the values haven't moved. But it's still there, just not where you'd want it.
>
>Naoto: using DIMENSION to change the number of columns in a 2-dimensional array causes the data to be "rearranged" rather than add or delete a column.
>
>I completely agree with the usage of quotation marks here. Rearranged yes, in the sense that we're now reading them six at a time instead of five. They weren't rearranged at all (as can be seen in the debugger), but we're addressing them in a rearranged manner.
>
>Al: Also, as recently discussed in another thread here, it's probably a bad idea to use "a" for the name of a variable (or array, probably doesn't make any difference) as it's a reserved "alias".
>
>I disagree with the second set of quotation marks here, it's really an alias, not "alias". And I felt safe enough using such a short variable name in a clean fresh session with no other variables or aliases or "aliases" in sight. In any other situation, my verbosity applies to my naming convention (which unfortunately, isn't a real convention or else I would have sent invitations to speakers first, then to attendees... I only have the booze so far).
>
>Regardless of all this, the ains( , , 2) doesn't work in VFP up to 9.2 (it does something, doesn't give an error, result is not usable), but it works in Chen's VFPA. Check results in the debugger.
Greg Reichert
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform