Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
REPLACE doesn't ....a feature????
Message
De
23/04/2001 20:06:06
 
 
À
23/04/2001 19:46:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00498797
Message ID:
00498801
Vues:
12
This message has been marked as the solution to the initial question of the thread.
>I quote from the VFP help file on the REPLACE command:
>
Note   If the IN clause is omitted, no replacement occurs
>if the record pointer is at the end of the file in the current
>work area and you specify a field in another work area.
>
>Huh? .... it's true...just try it...
>
>select table1
>replace table1.c with 'A'            &&init value
>select table2                        &&new workarea
>locate for .F.                       &&go eof
>replace table1.c with 'B'            &&try it
>?table1.c                            &&yeilds 'A'
>go top                               &&go bof of table 2
>replace table1.c with 'C'            &&try it
>?table1.c                            &&yeilds 'C'
>locate for .F.                       &&eof table 2 again
>replace table1.c with 'D' IN table1  &&try it with the IN clause
>?table1.c                            &&yeilds 'D'
>Would anyone like to explain the origin of this FODU ('feature of dubious utility') to me?
>
>Let me guess - if you fall off the end of a parent table, VFP is preventing you from altering the related child ... well fine. Then only apply the rule when the two tables are related (or better yet ... just write into the void).
>
>I got nailed by this obscure feature and I feel very lucky to have discovered the fine print at the bottom of the REPLACE help before spending hours trying to figure out why the replace wasn't happening.

This "feature" has been around as long as xBASE. My understanding is it has never been fixed because some programs might actually rely on it working this way.

FWIW the IN clause makes managing this easier than it used to be.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform