Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you remove blanks within a field
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00131900
Message ID:
00132031
Vues:
18
>>>>Is there a quick way to remove blanks within a field? For example PART NUMBER = 'TRG 011 4TGH 77K' to become 'TRG0114TGH77K'
>>>>Thanks.
>>>
>>>Hi Timothy,
>>>
>>>Everyone's told you that using STRTRAN() is the solution to your problem, and, of course, they're right. I thought I'd give you another, related piece of advice about the function. I can't recommend your using a literal string here. It can make it hard to read. I'd suggest using either:
>>>
>>>lcnewstring = STRTRAN(yourstring, SPACE(1), "")
>>>
>>>or
>>>
>>>lcreplace = SPACE(1)
>>>lcnewstring = STRTRAN(yourstring, lcreplace, "")
>>>
>>>It's much more readable, and, therefore, maintainable.
>>>
>>>BTW, the third parameter isn't necessary. If it's eliminated STRTRAN() replaces the specified character with a "" anyway.
>>>
>>>hth,
>>
>>What about STRTRAN(string,SPACE(1),SPACE(0))?
>
>Hi Ed,
>
>Yep, that works too, and is another improvement in readability. Unless, of course, you omit it altogether. However, on some monitors (and with some fonts) you're far more likely to mistake the number of characters in " " than in "". I used to hate trying to figure out how many spaces were used for padding back in foxbase when someone did a report using @ row, col SAY. Drove me nuts. Some folks say I haven't come back from that drive yet.:-)

These days any foxbase program drives me crazy :)
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform