Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP bug, and how to fix it
Message
De
06/03/2023 06:30:12
 
 
À
03/03/2023 14:09:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
01686313
Message ID:
01686343
Vues:
66
>>>Hi folks,
>>>
>>>For several weeks now I have been working on a Thor utility which will be available soon. This tool uses many Foxtools functions which are exposed in an object typically called loEditorwin, check https://github.com/VFPX/PEMEditor/blob/master/Documentation/pemeditor_editorwindow_object.md for details.
>>>
>>>My work has been delayed for a long time since the program failed occasionally, and seemingly with no pattern for when and how it failed. The errors were incomplete, inconsistent and the debugger didn't provide any help either.
>>>
>>>The program copies data programmatically back and forth between the editor and the clipboard, and manipulates it in between. But sometimes some of the data "disappeared" for no reason I could explain, and it made me lose my mind, and much of my hair...! :-)
>>>
>>>I was ready to give up, but as a last resort I tried to add a short delay. Lo and behold, that fixed it! And now I want to share it with all of you.
>>>
>>>To reproduce the error, try the following code:
>>>
>>>
>>>_cliptext=''
>>>For lnX = 1 to 10
>>>*  Wait Window '' timeout 0.001
>>>  _cliptext = _cliptext + Transform(lnX) + Chr(13)+Chr(10)
>>>Endfor
>>>Wait Window _cliptext
>>>
>>>
>>>Run it several times, and you will notice that sometimes the list of numbers isn't complete, and sometimes it is.
>>>
>>>Now remove the comment (*) and run it again. Now you will get the correct result every time!
>>>
>>>Conclusion: VFP needs some time to "settle" when you move data to and from the clipboard. A very small delay won't be noticeable, but it will fix the problem!
>>
>>Interesting. FWIW, on my development machine, I ran it 6 or 8 times and it worked perfectly each time without the delay.
>>
>>Tamar
>
>This is a longer test:
>clear
>_cliptext = ''
>For lnX = 1 to 10
>  For lny = 1 to 10
>     Wait Window '' timeout 0.001
>    _cliptext = _cliptext + Transform(lnY) + '-'
>  EndFor
>  wait window '' timeout 0.001
>  _cliptext = _cliptext + Chr(13)+Chr(10)
>Endfor
>?_cliptext
>
>The result was that there still are occasional dropouts, so I will do more test during the weekend.
>
>When I commented out the two Wait WIndow lines, the number of dropouts was sometimes high, sometimes low and a few times none...!

Yep, really weird behavior with this.

Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform