Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replacing spaces in a field
Message
From
09/08/2002 20:04:37
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
08/08/2002 18:14:15
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00687756
Message ID:
00688228
Views:
17
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform