Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slow down display???
Message
From
22/06/2001 02:27:03
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/06/2001 00:42:47
Peter Brama
West Pointe Enterprises
Detroit, Michigan, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00522275
Message ID:
00522285
Views:
8
>I have a program that processes some data records at the click of an on screen button. Because of the SPEED of VFP, the client is worried it isn't doing anything. Sooo, in order to "keep the client happy", I decided to add a status line that will update as the records are processed. The status line is maintained in the "loop" like thus:
>
>thisform.mystatus.value="Record #" + str(recctr) + " of " + str(recmax) + "processed..."
>thisform.mystatus.refresh
>
>Well, again, because of the fantastic speed of VFP, the status line, basically, never appears to show anything. To double check, I put a WAIT WINDOW with this data and a TIMEOUT .25 and saw that it changed (although it also put a PRESS ANY KEY several times over in the window).
>
>So, I need to put in a delay after my refresh to allow the data to display for the client. I tried a FOR I = 1 TO 100000 and NEXT and that seemed to work although I only saw about every 3 or 4th one. I can keep bumping this up to a higher value until all is visible but then I believe on a slower machine, it will slow even more.
>
>There has to be a better way to do this.
>
>Suggestions?

Peter,
1st option is to rewrite in VB < bg > Slowing down is hard in VFP :)
For loop is dependant on machine speed.
Instead of slowing down I would probably show before and after data say in a grid ( and probably highlighting the record processed with a delay :).
Anyway this would sleep for n millisecs :

declare Sleep in win32API integer SleepTime
*Your code
*Message
*Delay here
Sleep(lnMilliSecs)

Sleep would be machine speed independant (or I think it is). If your code is a bulk processor like replace all, select .. then in that call a UDF that would display message and sleep (oh my - slowing down FP is hard:). ie:
replace all for myDelay(300)

Function myDelay && Actually adding over time needed to display string
lparameters tnMillisecs
thisform.txtStatus.Value = "Record #" + ;
   transform(recctr) + " of " + transform(recmax) + "processed..." 
Sleep(tnMillisecs)
Or use another slower control like a Progress bar < g >.
thisform.MsBar.Max = recmax

replace all for UpdBar(recctr)

*UpdBar
lparameters tnCurrec
thisform.MsBar.Value = tnCurrec
* And if you still need :)
Sleep(200)
Or if Excel is an option your lifesaver would be VBA's slowness :) Create an excel sheet with your data, make Excel VISIBLE, as you process in VFP also update cell with (compared to Excel side speed VFP side would be quite ignorable) :

oExcel.ActiveWorkBook.ActiveSheet.Cells(recctr,lnCol).Value = luValue

Do not use with..endwith to 'lose' speed < g >. I believe this approach would be enough to make your client beg for old 'doing nothing' thing :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform