Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advice how to replace special chars with blank
Message
 
 
To
09/02/2005 14:53:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00985315
Message ID:
00985336
Views:
17
Here is a procedure I use:
PROCEDURE StripString
   LPARAMETERS tcString, tnAllow
   IF VARTYPE(tcString) <> [C]
      RETURN NULL
   ENDIF
   IF VARTYPE(tnAllow) <> [N]
      RETURN NULL
   ENDIF
   LOCAL lnType, lcReturn
   lnType = ABS(tnAllow)
   LOCAL lcAllowed
   DO CASE
      CASE lnType = ALLOW_ALPHA_ONLY
         lcAllowed = [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]
      CASE lnType = ALLOW_NUMBER_ONLY
         lcAllowed = [1234567890]
      CASE lnType = ALLOW_ALPHA_NUMERIC
         lcAllowed = [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890]
   ENDCASE
   IF tnAllow < 0  && not allowed
      lcReturn = CHRTRAN(tcString, lcAllowed, [])
   ELSE
      lcReturn = CHRTRAN(tcString, CHRTRAN(tcString, lcAllowed, []), [])
   ENDIF
   RETURN lcReturn
ENDPROC
>Hi all,
>
>I have used this line to test and works fine
>
>STRTRAN(ALLTR("xxx'xxxxxx"), "'" , "" ) gives me xxxxxxxxx GOOD output.
>
>what happened if I like to replace everything other THAN THAN
>
>letters,numbers,space,period,dash,underscore,brackets
>A..Z, a..z, 0..9, space, . , - , _ , ()
>
>i.e :
>
>' with blank
>" with blank
>; with blank
>? with blank
>....
>....
>...
>
>in the single process if possible.
>
>Any advice or coding samples would be really appreciated .
>TIA
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform