Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Range of values
Message
De
05/11/2001 15:54:55
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00577572
Message ID:
00577593
Vues:
25
>>>Does anybody have a function that converts a range of values into individual values? The best example, I think, is the range of pages in newer versions of MS-Word, where the user can type "1, 3-5, 7". I want this converted to a form that can easily be processed, like the string "1, 3, 4, 5, 7", or an array or cursor with the corresponding elements.
>>>
>>>I am sure I can write the function myself, but it seems to me this is a rather involved procedure.
>>>
>>>Hilmar.
>>
>>It doesn't seem complicated to me. I just wrote it in my head. Hint: use for loop :)
>
>Ok, here is an algorithm:
>
>Parse each element of the string into array laNumbers (actually char vals)
>Check each laNumbers[i] if contains "-". If so, find first and last element and do inner loop
>
>    for i=lnFirst to lnLast
>        lcStr = lcStr+transform(m.i)+", "
>    next
>
After your first answer, I was starting to think along these lines, too... Yes, it is simpler than I thought at first.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform