Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Loop through record's fields
Message
De
21/09/2007 01:29:24
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
21/09/2007 00:27:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01255535
Message ID:
01255883
Vues:
10
>>How can I loop through all the fields (assuming only one record to start, but there could be more eventually) and concatenate all the resulting values into one string?
>
>Jay,
>
>the approach you discuss later on is workable - but if the "more eventually" comes into large table range and/or the table has many fields, the concatenate operation itself (because the string has to be recopied again and again) can become troublesome.
>
>Adding to a file will become faster (because the no string reallocation occurs) or an alternate approach like building line concatenating all fields in one instruction will help. Again, the value here is not saving the loop by replacing it with a makroexpansion, but reducing the number of string movements of growing strings. On multimillion record tables it would be reccomended to add the bracketing scan / endscan and execscript and compile that so that you eliminate the makroexpansion for each record.
>
>The time needed will depend on the string length and the number of operations: if the scan loop takes more than a second (or needs to be performed in a loop as well) take a look at the options described. 10**5 operations are a breeze, around 10**6 you will start to feel the exponetial perf drag.

And we already have a single method which will do it in one step:

_vfp.datatoclip(,,3)

Then it's only a matter of manipulating that one string on the clipboard into a format we want. The fields are separated by tabs, records by CRLF (or was it just CR?). Nice and easy.

There's the trouble with the field names being in the first line, but it takes just two commands to remove it.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform