Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A neat little 'gotcha' in VFP
Message
De
30/06/2006 08:45:27
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
29/06/2006 09:13:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01132511
Message ID:
01133039
Vues:
27
Hi Ravi

>I agree with Calvin. Perhaps we are giving too much emphasis on using m dot with variable. I agree that the command -- lnCounter = m.X will definintely not refer to the field X from the current table and lnCounter = X may use value from the field X. But what will happen if there are multiple tables having field 'X' open . Do we know field from which table will be used? (Depends on which one is selected).
>
>Consider the code
>
>USE FIRST in 0
>USE SECOND IN 0
>GO TOP
>REPLACE CODE WTIH '123'
>
>Will it replace the Code field in the FIRST table or SECOND or in someother table? Isn't there is a strong case for using table prefix (e.g. REPLACE FIRST.CODE) in commands?

REPLACE field with expression IN alias.

Ever wonder why you're allowed to put the alias prefix?

SET ORDER TO SOMETAG IN SECOND
SELECT FIRST
SET RELATION TO SOMETHING INTO SECOND
REPLACE ALL SECOND.FIELD WITH EXPRESSION IN FIRST

That's the only way adding the alias is REQUIRED. Every other time it's redundant and wasteful in FOX/VFP/DBASE. I seldom use relations like that. So now, when you see a replace in my code, you can tell things are strange if the aliases are included. Weird stuff stands out against the normal stuff so you know to take extra care.

However, when writing SQL (even in VFP), you should include the aliases.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform