Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with the CHRTRAN() function
Message
De
16/11/2001 12:33:15
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
16/11/2001 04:29:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00582596
Message ID:
00582796
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>Hello,
>
>As part of a simple data cleaning routine I am using the following code:
>
>lcNameKey = CHRTRAN(lcNameKey, " ',./;#[]{}=-_+()*&^%$£!z", "")
>
>99.9% of the time this code does exactly what you would expect...
>
>However, every once in a while the code instantiates a Fatal Exception C000000005 error (I may have incorrect number of 0's but you know the one I mean)
>
>I cannot see any pattern in the value coming in as lcNameKey, usually a surname or forename and surname.
>
>I am running VFP6 SP5.
>
>The code is called from within a SCAN loop, the error occurs less on low data quantities (< 1000) and more on quantities into the tens of thousands.

The bug existed as Sergey pointed, and if you were replacing large amounts of any character with nothing (i.e. not with another character) it was slower than a corresponding strtran() or eventually crashing. Glad to hear this was fixed.

If the error reoccurs, you can use a workaround: instead of using a bunch of strtran() for each character in turn, which would be safer but awfully slow, you can do something like this:
lcNameKey = CHRTRAN(lcNameKey, " ',./;#[]{}=-_+()*&^%$£!z", "#########################")
lcNameKey=strtran(lcNameKey, "#","")
This way you get both the speed of chrtran() for multiple char-by-char replacement, and the safe way of strtran()'s char-for-nothing replacement.

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