Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Bernard Bout
  Where is Bernard Bout?
 Brisbane
 Australia
 Bernard Bout
 Tags
Subject: RE: Fractions of Pixels
Thread ID: 112443 Message ID: 112514 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: Visual Basic
Date: Thursday, November 09, 2006 8:24:06 AM         
   


> > > Hello Experts,
> > >
> > > I have a another PROBLEM. I need your help.
> > >
> > > I created a progress bar with 2 shapes on a form. The outer shape1 has a width of 400. The Inner shape2 starts with 0. There are 239 records in a table. I calculate the incremental value with this formula :
> > > mDONE = 400 / RECCOUNT() which in this case works out to 400/239 = 1.6736.
> > >
> > > then i use:
> > > SELE mFILE
> > > GO TOP
> > > DO WHILE NOT EOF()
> > > thisform.shape2.width = thisform.shape2.width + mDONE
> > > SKIP
> > > ENDDO
> > >
> > > My Problem.
> > > When I run the form the inner shape2 ends up halfway within the outer shape1. It is not covering the full length of 400. With (1.6736 * 239) it should end up at 400.
> > >
> > > If i use CEILING(mDONE) the length will exceed 400 AND overshoot the outer shape1.
> > >
> > >
> > > With FPW the above formula worked because the unit of calculation was 'columns'. How do i make it work with pixels in VFP.
> > >
> > > Another very important question:- Where should this code reside? I have put it in the 'init' proceedure of the form
> > >
> > >
> > > Thanks!
> > > kulwant

> >
> > Kulwant,
> >
> > You need to calculate the progress in terms of percentage:
> >
> > lnRecCount = RECCOUNT([MyTable])
> > lnCounter = 0
> > SCAN
> >    lnCounter = lncounter+1
> >    lnPctProg = INT((lnCounter/lnRecCount)*100)
> >    IF MOD(lnPctProg,5) = 0
> >       thisform.shape2.width = lnPctProg * 4 && 400 MaxWidth/100%
> >       ThisForm.Shape2.Refresh()
> >    ENDIF 
> >    && do what ever it is that you need to do
> > ENDSCAN
> > 

> >
> > Note the SCAN/ENDSCAN - this is faster than DO WHILE. Note also that updating at every loop will definately slow down the works. Twenty refreshes should show movement but at the same time, should not slow down the works. Do some tests - even a WAIT WINDOW NOWAIT every loop takes a fair amount of time.
> >
> > Ken
> > You shall know the truth - and the truth shall set you free. (John 8:33)

>
> Hi Ken and Kulwant
>
> I have dispensed with progress bars long ago as not being worth the trouble. I once came across some code that I had to work on where the simple fact of removing the "rogress bar" thingy caused the loop to speed up from taking a few minutes to seconds believe me.
>
> Now if there is any feedback needed,I just display a wait window NOWAIT and carry on. No progress bars for me.
>
> And thats PROGRESS (forgive the pun) IMHO


For the most part, I agree with you, but there are times when a progress bar does make sense. Normally, all I do is WAIT WINDOW NOWAIT [Updating...], but for a long processes where the update can take several minutes, a progress bar does make sense. I update the progress bar at every 5% - that way, I only interrupt the progress loop 20 times. It does not really add that much to an already long process, and it is far better than the alternative - the user thinks the thing is hung so she Ctrl+Alt+Del -> task manager -> End Task in the middle of a large update.

I have one user who continued to end the task even after being repeatedly told not to. We finally got her to stop issuing the three fingered salute (she was told that if she did it again, discipliary action would be taken) and she decided that it was hung again so she went to her power bar and turned it off! Giving this user a progress bar made far more sense and saved a lot of time. It didn't save her more time, it save me more time. I no longer have to pick up the peices of an aborted update.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Fractions of Pixels Posted by kulwant singh @ 11/8/2006 4:37:25 PM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/8/2006 4:59:15 PM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/9/2006 7:12:24 AM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/9/2006 8:24:06 AM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/10/2006 7:45:48 AM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/10/2006 11:59:55 AM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/10/2006 10:23:33 PM
RE: Fractions of Pixels Posted by Ken Murphy @ 11/11/2006 2:03:23 AM
RE: Fractions of Pixels Posted by Bernard Bout @ 11/12/2006 3:27:30 AM
RE: Fractions of Pixels Posted by Yuri Rubinov @ 11/8/2006 5:12:09 PM
RE: Fractions of Pixels Posted by Carlos Alloatti @ 11/8/2006 8:32:52 PM