Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP bug, and how to fix it
Message
From
03/03/2023 11:06:14
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
VFP bug, and how to fix it
Miscellaneous
Thread ID:
01686313
Message ID:
01686313
Views:
105
Likes (1)
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!
Next
Reply
Map
View

Click here to load this message in the networking platform