Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing unprintable characters in character and memo f
Message
De
09/12/2004 10:17:45
 
 
À
08/12/2004 09:56:20
Jim Winter
Jim Winter Consulting
Hinesburg, Vermont, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00967248
Message ID:
00968014
Vues:
10
Thanks for the reply. I missunderstood your original posting and thought you were suggesting I create a variable to do all the replaces at once. I do have several questions on your code.

1. Why do you use EVALUATE(taField) instead of macro substition of the vairable, i.e. is it faster?

2. Why call a function instead of using inline code?


>Claude,
>
>OK, I hadn't tested what I suggested and it had some problems. Here is some code I have tested that works. I'm not sure what characters you are eliminating so I just picked 2 at random and ran the following test program with a field in the table that has them plus a number of embedded spaces.
>
>#DEFINE BADCHARS CHR(128)+CHR(129)
>#DEFINE ONE SPACE(1)
>#DEFINE TWO SPACE(2)
>
>LOCAL lnFldCnt, lnPtr
>LOCAL ARRAY laFields[1]
>SET STEP ON
>IF USED('Tran0')
>   SELECT Tran0
>ELSE
>   USE Tran0
>ENDIF
>
>lnFldCnt = AFIELDS(laFields)
>
>SCAN
>
>   FOR lnPtr = 1 TO lnFldCnt
>      IF laFields[lnPtr,2] = 'C' OR ;
>         laFields[lnPtr,2] = 'M'
>         = Cleanup(laFields[lnPtr,1])
>      ENDIF
>   ENDFOR
>
>ENDSCAN
>
>FUNCTION Cleanup
>LPARAMETERS taField
>LOCAL lcString1, lcString2
>
>m.lcString1 = EVALUATE(taField)
>
>m.lcString2 = CHRTRAN(m.lcString1,BADCHARS,'')
>
>DO WHILE TWO $ m.lcString2
>   m.lcString2 = STRTRAN(m.lcString2,TWO,ONE)
>ENDDO
>
>IF LEN(ALLTRIM(m.lcString2)) < LEN(ALLTRIM(m.lcString1))
>   REPLACE (taField) WITH m.lcString2
>ENDIF
>RETURN
>
>Hope this is a little more helpful!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform