>Hi,
>
>I am converting from a few DBFs to SQL Database. I have a DO WHILE loop and a couple of DO WHILE within it.
>
>I have to run this routine several times, for different values. Sometimes, only after about 3 minutes, I get the message that VFP stopped working.. and the only thing I can do is stop/close program.
>
>Is it something in my code or how can I make VFP run until the end?
>
>TIA
>
>UPDATE. It appears that it happens after about 1000 records are added to a table in SQL Server. And I can see in VFP IDE that at certain point the record pointer in a DBF moves slowly. Must be something to do with memory. How can I "clear" the memory on every loop in DO WHILE?
>
>UPDATE 2. I set a "test" point that writes to a text file every PK value assigned by SQL server to a table. And it seems to always stop on PK 1001. Could it be that SQL Server Express 2014 has a limit of 1000 records in a table?
No, I use that and got some tables with half a million records.
Since I'm regularly doing such conversion (from different sources, but always into SQL) I've run into this problem few years ago. Simply, newer windowses (I'd say from the Vista and up, i.e. all of them in the last ten years) periodically poll all active apps (i.e. those shown on the toolbar as having a desktop window) with some kind of ping message. VFP apps don't react to that while running a long prg so this is what I call on every 10 records processed (note that it doesn't react on each call):
Procedure tapdance(tn1, tn2)
#Define hWindowsTapInterval 4.56
If Seconds()> This.lastTap
DoEvents Force
Wait Window Textmerge(Program(Program(-1)-1)+0hd+" <<tn1>>/<<tn2>>") Nowait
This.lastTap=Seconds()+hWindowsTapInterval
Endif
In the init of this class, .lastTap=0 (could actually set it to seconds() before processing the first record, so it wouldn't always report "1/n". When calling this, pass two numbers, one for the current record and one for the recc() - so this also works as the progress indicator.
The point is to issue DoEvents Force, which temporarily puts VFP into state when it checks for any system messages and responds to them, thus giving a "yes I'm alive" response, so its screen doesn't get milky and it doesn't get a "(not responding)" suffix to _screen.caption - hey, it just responded. The 4,56 seconds interval I decided by trial and error, seems often enough so Windows lets my conversion run and not so often that it would slow down the conversion significantly.