Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you extract parts of a string in a field?
Message
 
 
À
21/12/2000 08:49:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00455835
Message ID:
00455855
Vues:
29
This message has been marked as the solution to the initial question of the thread.
>Hi All! How do you extract certain parts of a string. Like I want to replace the first three digits of a field with something. ie. 50-1020 with 95-1020
>Anything that begins with 50- I want to replace it with 95-
>
>Thanks in advance for your help!
>
>Joe


Ho Joe,
SET EXACT OFF
REPLACE FOR Myfield = "50-" ;
    Myfield WITH "95-" + SUBSTR(Myfield,3)
Be aware that REPLACE FOR locks table for it duration.

Alternatively you can use SCAN + REPLACE. In this case Foxpro locks only one record at a time.
SET EXACT OFF
SCAN FOR Myfield = "50-" 
    REPLACE Myfield WITH "95-" + SUBSTR(Myfield,3)
ENDSCAN
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform