Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing spaces in a field
Message
De
09/08/2002 20:04:37
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
08/08/2002 18:14:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00687756
Message ID:
00688228
Vues:
16
>Is there anyway to replace spaces in a table field? I have a table where I need to replace all spaces in that field with a hyphen. I have tried :
>replace substr(field,2,1) with '-';
>for substr(field,2,1) = ' '
>
>This gives me an unrecoginzed phrase error. Is there a better way to do this? Please help!!! Thanks.

Strtran() is handy when you replace string for string, like StrTRan("abcdefgh", "def", "Default"), but if you want character for character, ChrTran is faster:
replace all field with chrtran(field, " ", "-")
And just to keep the tradition ("it can be done three ways in Fox, or it ain't worth doin'"), if you want to get rid of the space on second character only:
replace field with stuff(field,2,1,"-") for  substr(field,2,1) = ' '
All three of these functions have their uses, it's good to keep them in mind. I've often delegated text processing from Word to Fox, because VBA for Word lacks these functions. OK, mid$ is roughly equivalent to Stuff, but the other stuff (plus strconv(), occurs() etc) is sorely missing.

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
Répondre
Fil
Voir

Click here to load this message in the networking platform