Copy to array
- kevclark64
- Posts: 127
- Joined: Thu Aug 15, 2019 7:30 pm
- Location: USA
Copy to array
I mentioned some issues with Copy to Array a while back, which have been fixed, but I don't think I ever mentioned this. When you use Copy to Array with Foxpro, the length of the array will be truncated to the number of the items copied. With XSharp, the original length of the array remains unchanged regardless of items copied. So, in Foxpro if you dimension an array as 1000 items but then Copy to Array copies 50 items then the array now has a length of 50. In XSharp, doing the same thing would keep the array at 1000 items.
Copy to array
Kevin,
I have made a ticket for this, so we will not forget it:
https://github.com/X-Sharp/XSharpPublic/issues/1262
Robert
I have made a ticket for this, so we will not forget it:
https://github.com/X-Sharp/XSharpPublic/issues/1262
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Copy to array
Kevin,
The example file is the Categories table from the Northwind database. This has 8 rows and 4 fields. The last 2 fields are memo.
After running the test, the array has the size it had before and the memo fields are not stored in the array.
So it looks like FoxPro does not resize the array.
Or am I overlooking something?
Robert
I just tested this in FoxPro with the following code:kevclark64 post=26422 userid=5303 wrote:I mentioned some issues with Copy to Array a while back, which have been fixed, but I don't think I ever mentioned this. When you use Copy to Array with Foxpro, the length of the array will be truncated to the number of the items copied. With XSharp, the original length of the array remains unchanged regardless of items copied. So, in Foxpro if you dimension an array as 1000 items but then Copy to Array copies 50 items then the array now has a length of 50. In XSharp, doing the same thing would keep the array at 1000 items.
Code: Select all
SET DEFAULT TO "C:Test"
PUBLIC ARRAY aTest(10,5)
USE Categories
COPY TO ARRAY aTest
? RECCOUNT() && 8
? FCount() && 4
? ALEN(aTest) && 50
? ALEN(aTest,1) && 10
? ALEN(aTest,2) && 5
? aTest(1,1), aTest(1,2), aTest(1,3), aTest(1,4) && 1, Beverages, .F., .F.
? aTest(8,1), aTest(8,2), aTest(8,3), aTest(8,4) && 8, Seafood .F., .F.
? aTest(9,1), aTest(9,2), aTest(9,3), aTest(9,4) && .F., .F., .F., .F.
USE
After running the test, the array has the size it had before and the memo fields are not stored in the array.
So it looks like FoxPro does not resize the array.
Or am I overlooking something?
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
- kevclark64
- Posts: 127
- Joined: Thu Aug 15, 2019 7:30 pm
- Location: USA
Copy to array
I have to apologize because I made a mistake here. I'm not sure what I was doing when I got the results I reported, but the FoxPro help is clear that the array isn't truncated: Each successive row in the array is filled with the contents of the next record in the table. If the array has more rows than the table has records, any remaining rows aren't changed. If the array has fewer rows than the table has records, any remaining records aren't stored to the array.
Again, apologies for the error.
Again, apologies for the error.