Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing unprintable characters in character and memo f
Message
De
08/12/2004 09:56:20
Jim Winter
Jim Winter Consulting
Hinesburg, Vermont, États-Unis
 
 
À
07/12/2004 14:48:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00967248
Message ID:
00967736
Vues:
9
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!
Jim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform