Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Displaying elements of strings in simple way howto
Message
 
 
À
14/02/2005 06:44:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8
Divers
Thread ID:
00986136
Message ID:
00986571
Vues:
24
Terry,

The parameters of a FOR loop are evaluated only once when the loop begins so only time saved would be on the second evaluation of the LEN(cName). I prefer to use the size of array directly.
FOR i=1 to ALEN(aLetters)
>Tore, perhaps you can advise me. I would have thought that:
>
>
cName = "Zakaria"
>lnLenCName = LEN( cName)
>DIMENSION aLetters( lnLenCName)
>FOR i = 1 to lnLenCName
>  aLetters[ i] = SUBSTR( cName, i, 1)
>  ? aLetters[ i] +  CHR(13)
>ENDFOR
>
>would have been marginally faster (more so if a huge string), but at least more efficient, as LEN( cName) only has to be evaluated once, and not once then also every time through the loop. Perhaps this doesn't matter with for loops?
>
>Terry
>
>>Not much shorter, but a little:
>>cName = "Zakaria"
>>DIMENSION aLetters(LEN(cName))
>>FOR i=1 to LEN(cName)
>>  aLetters[i] = SUBSTR(cName,i,1)
>>? aLetters[i] +  CHR(13)
>>ENDFOR
>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform