Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field overlaping local variable - Bug or not ?
Message
De
05/06/2003 09:58:44
 
 
À
05/06/2003 09:38:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00796540
Message ID:
00796673
Vues:
15
Sorry, Srdjan, but I still can't call this a "problem" or "bug".
It's kind of like the English language forcing me to put periods at the end of my sentences to make them more readable - it's just something one has to learn to do.

In your case you have to learn that SCATTER MEMVAR can pose problems with defined memvars and code to make allowances for that. In your code the SCATTER effectively negates what the STORE did in the line above. it effectively does a
m.lLocal = lLocal
m.lPublic = lPublic
m.lPrivate = lPrivate
Since m.lLocal is defined as LOCAL then the (private) m.lLocal created in the function is simply discarded when the function ends. Privates and publics are of course accessible from lower functions so they get updated with new values by the SCATTER.
Similarly, when forced to add a specific field name to a table one HAS TO CHECK for collisions with existing defined memvars.
These are just the "rules" of coding in VFP.

What error message would you propose, and under what circumstances?



>P>Srdjan,
>>
>>But this is already well known by VFP and it has the "m." to take care of it.
>
>As I said, I understood what is happening and I took care of it
>point is that one error message would make all the difference ...
>
>Perhaps u hv code builded up in the functions and classes (framework developed years ago) and all of sudden u run across table that HAVE to have field(s) named this way. Even if u used m.xx all along u would still run into problems when u deal with scatter/gather constructions to populate data - again u will run into problems as I will show in this example:
>
>
>local   m.lLocal
>private m.lPrivate
>public  m.lPublic
>
>store .t. to m.lLocal , m.lPrivate  , m.lPublic
>
>=form_call()
>
>if m.lLocal = .t.
>    wait wind 'Local ok'
>else
>    wait wind 'Local not ok'
>endif
>
>if m.lPublic = .t.
>    wait wind 'Public ok'
>else
>    wait wind 'Public not ok'
>endif
>
>if m.lPrivate = .t.
>    wait wind 'Private ok'
>else
>    wait wind 'Private not ok'
>endif
>
>
>function form_call
>    create cursor test ( lLocal L, lPrivate L , lPublic L )
>    append blank
>    scatter memvar
>
>
>
>
>
>Even If we leave aside code purity & speed for the moment
>we still hv problem!
>Code flow gets influences from 'outer space'
>without any warning !
>
>I just don't like it :)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform