Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transforming an ARRAY
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00153394
Message ID:
00154814
Vues:
18
Jim,

Your not going to believe what this other fellow came up with but it does work. Here's my reply to him on another list, and my revised code of his suggestion.
---------------------------------------------------------
Frank,

You win! This works. Here is the test routine:

DIMENSION laTest[2,5]
laTest[1,1] = "Scott"
laTest[1,2] = "Kirsten"
laTest[1,3] = "Peter"
laTest[1,4] = "Andy"
laTest[1,5] = "Ralph"
laTest[2,1] = "Hurlbert"
laTest[2,2] = "Schultz"
laTest[2,3] = "McKay"
laTest[2,4] = "Hall"
laTest[2,5] = "Samuels"
*
clear
display memo like laTest
LOCAL lnRows, lcCol, lnCols
create cursor cur (col1 c(20), col2 c(20), col3 c(20), col4 c(20), col5 c(20)) && one column for each array
append from array laTest && copy array into cursor
lnRows = reccount("cur")
lnCols = alen(laTest, 2)
declare aTargetArray(lnCols, lnRows)
for i = 1 to lnCols
lcCol = alltrim(str(i))
select col&lcCol from cur into array aTempArray && one select for each column
=acopy(aTempArray,aTargetArray,1,lnRows,i*lnRows-lnRows+1)
endfor
display memo like aTargetArray

This does what I need. It's takes the output of an ADO recordset's "getrows" method and turns it into something a listbox or combo can use.

Now, this method was faster by about 20% on a recordset with 2800 rows. I suspect the gains would be more for higher numbers of rows and probably less for smaller. The old array rearrange would probably be faster for recordsets of less than 1000 rows; 1000 is my guess for the breakeven between the two methods.

Of course, for smaller methods it doesn't matter because both routines are "fast enough."

One note, things get complicated if you start dealing with lots of data types. This works real well for a list of strings but start throwing in integers and dates and building the cursor is going to be a pain in the butt.

Thanks, Scott


>>Jim,
>>
>>You're right about the size of the array. My current recordset is 3,000 records, so 65,000 won't be a problem.
>>
>>ACOPY() won't rearrange the array. The array is WIDE by TALL and I need it TALL by WIDE.
>
>Scott,
>
>In that case your code is about the only way you can get it done. Inverting matrix takes time.
>
>You might do better to leave it alone and process it the way it is.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform