Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UDF's in a FOR stmt
Message
De
27/02/2000 19:02:16
David Abraham
David Abraham & Associates, Inc.
New York City, New York, États-Unis
 
 
À
26/02/2000 17:27:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00338042
Message ID:
00338243
Vues:
12
>>Try this fun experiment in VFP 6.0 (this problem may apply across all FP's but I am using VFP6.0).
>>
>>Experiment One
>>++++++++++++++
>>from the command window:
>>
>>USE
>>BROWSE FOR MOD(VAL(),3) = 0
>>
>>A no brainer, right? You see every third record in the table.
>>
>>
>>Experiment Two
>>++++++++++++++
>>create a udf(),
>>
>>FUNCTION filt_exper
>>xxx = MOD(VAL(),3) = 0
>>RETURN xxx
>>
>>then, from the command window:
>>
>>USE
>>BROWSE FOR filt_exper()
>>
>>A no brainer, right? You still see every third record in the table.
>>
>>
>>Experiment Three
>>++++++++++++++++
>>edit the udf() thus,
>>
>>FUNCTION filt_exper
>>xxx = MOD(VAL(),3) = 0
>>WAIT WINDOW STR(RECNO()) + " " + IIF(xxx=.T.,"YES","NO") TIMEOUT 1.0
>>RETURN xxx
>>
>>then, from the command window:
>>
>>USE
>>BROWSE FOR filt_exper()
>>
>>Whoa, what is going on here? This is STRANGE behavior.
>>
>>Now, the real question is: are YOU experiencing this strange behavior too, or is it only my installation of VFP 6.0 that is acting in such a funny way? Please, please let me know your results. And if you DO get my strange behavior, is this a known phenomenon in VFP (problems using a udf() with a FOR statement) and where can I read about it.
>>
>>Caution: Do NOT try this on a large table. The best size is about two dozen records.
>>
>>David
>
>First, as you noticed, your VAL() expression is being lost because of UT's attempt to interpret it as an HTML tag. I used VAL(RECNO()) which is equivalent for these purposes.
>
>I get the same behaviour in VFP5. I believe MS would say this is "by design". I think the key to understanding this is that a BROWSE re-evaluates the BROWSE filter/condition each time the Browse window gets the focus. When the WAIT WINDOW fires, the BROWSE loses the focus, then it gets it back - and re-evaluates the conditions. So, you get recursive calls to the filter conditions, which as you pointed out, will take a prohibitively long time with a large table.

+++++++++++++++++++++++++++++++++++++++

Hi Al,

And thanks for taking the time to do the experiment and write me back.

You're right, there may be some sort of justification for that FINAL behavior. But was it your experience (it WAS mine!) that the wait window showed movement from the top of the table to the bottom, then from the bottom to the top, and it displayed twice for records that passed the selection criteria, and it also displayed random movement before it settled on the top record of the browse.

Weird!

David
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform