Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put a progress bar? 13

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
578
PH
Hi experts... my application usually shows a lot of records... with this sometimes, nothing shows and it just pop out when done... is it possible to put a progress bar so that the user would see that there is something going on while the computer generates the report? Thanks in advance...
 
Mandy.
Just my humble opinion so I am likely to be shot down in flames !

You don't really need a progress bar for the "report" generation as that is usually Very fast

However where this "may" become necessary is in the data extraction phase. ( I always extract data to a cursor and then report on it, rather than executing a report for for criteria = ??)

Displaying a progress bar will take longer than not, as you need first need to find out how many records are returned and then show the bar

my personal preference is just a simple "Please Wait - Processing" form of window that gets released when data extraction is completed

the only other thing i "sometimes" do is a wait window show a records extracted of records to process - but that invariable needs a doevents in order to update the display, which will definitely slow things down.

at the end of the day it's a balancing act between speed of data retrieval / user experience / Ease of programming and code maintenance


Colin
 
Mandy, are you thinking of on a form, or a report as Colin says?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Hi Colin and Griff... i was wrong when i said report.. i mean form... extracting data from cursor to a grid... Im sorry... it take sometime... "Please wait... processing..." would be fine.... is it a messagebox? if it is? where to put the messagebox? isnt it that messagebox will wait for the user to click button? if i will put a timer, the timer might be short or too long before data and the grid would appear... how will the "processing..." appear and dis appear once data is displayed? Thanks...
 
Well, if you are just looking for a telltale, I would put a label or textbox on the form, perhaps with an additional image of
a timer (which you could change your cursor to as well) and put the 'please wait...' on there (as caption or value) while you gather
your data for presentation. Alternatively, or additionally, you could display a value or set of values from your subset as
it is processed (item number or description) - that would change as you gathered data. Or, you could offer a counter saying you
had processed 10 out of 10,000 if you knew a count for the range you are looking at.

For graphical representations, when I'm assembling a zip file for example, I put 10 or 20 squares in a row on the form starting with them all white
and change them to blue as progress is achieved (checking how many files had been zipped up against the total number)... or you could go all Star Trek
and just scan a bar(s) in the same way if you don't have a total to measure against.

For all these approaches, I would only update the data once in every (say) 10 or 100 records/files processed as appropriate or you will
actually make your extraction process slower.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Mandy,

Several points here.

First, to put up a "Processing, please wait" message, you need to use a so-called Wait window:

[tt]WAIT WINDOW "Processing ... Please wait" NOWAIT[/tt]

The NOWAIT keyword is vital. Without it, processing will pause for as long as the window is on the screen.

Secondly, a better approach from the user's point of view is to display the percentage of work that has been done (or the percentage that is remaining). That's quite simple to do (and I'm sure we can all give you examples if you need them). But they generally only apply if you are doing some sort of processing in a loop. If you are using SQL SELECT to generate your cursor, this sort of progress bar is no good because there will be no opportunity to interrupt the SELECT to update the display.

Finally, Colin says that "Displaying a progress bar will take longer than not, as you need first need to find out how many records are returned ... ". That's not quite right. It's true that a progress bar will often slow down the process. But the reason for that is the need to update the screen. Outputting information to the screen is a relatively slow process - not so slow that it would normally make any difference - but it will have an effect if you do it thousands of times in a loop.

In general, a progress bar is a good thing to include, but keep the above points in mind.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

to clarify what i was saying..

I do agree that a progress bar is a good thing ( if you are extracting data in a loop or a scan)

for a scan for .... You will not know in advance how many records you are going to be processing over

Hence my comment that it would be slower, you need first of all to work out the scope of the extract before extracting and displaying a percentage progress

it was perhaps a specific case and not a general truism, apologies.

but 100 %^ definite that some measure of progress is what users want , there's nothing worse than staring at a screen that looks as if it has hung

Re the please wait processing message being a wait window, I don't use a wait window for that

I have a form called for example "pleasewait" that is non modal and takes a parameter of a string. that string is used to populate the caption of a label that is on said form.
that way the same form can be used for many different messages, and it is up to the calling code to release this "Pleasewait" Form (window) as required

sometimes i get a bit fancy and also pass font and size and attributes too ! you can pretty much make it do what you want, and centre it on screen rather than being unobtrusive in the top right corner

I have been lurking here for a long time, and thought perhaps time to share and in doing so learn a little more

Colin

(All Fox Flavours since 1985 and still full time employed working on huge projects with it )

 
Mandy,

There is another approach you could take, which would be very simple to do, and would be suitable even if the process is a single command such as SQL SELECT.

All you need is an animated GIF. That's a graphics file where the image changes slightly every couple of seconds or so. After a few changes, it goes back to the original and the cycle repeats. In other words, it gives the illusion of movement.

All you have to do is to drop the image file on your form. Doing that generates an Image control. At design time, or in the form's Init, set the Image's Visible property to .F. Then, at the start of the long process, set it back to .T. And when the process has finished, set it back to .F.

This won't be a true progress bar. It won't give any indication of what percentage of the process has yet to be done. But the animation will give the user some measure of reassurance that something is happening behind the scenes.

So, where do you find an animated GIF. Well, here is one with my compliments. Others are available from the usual graphics download sites.

working_ani_h5iory.gif


Just right-click on this image and select "Save Image As... " (or something similar, depending on your browser). That will let you save the image in a folder of your choice.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike, not negative at all - it is good to have a sensible, reasoned discussion

With Fox, and indeed all languages, there is seldom a "right" way of doing something.

there are many ways to skin a cat and which one is "best" will depend on many factors - and we commenting here will not be aware of all of them

Mandy for example, is obviously an inexperienced developer, but she seems eager to learn.

for her therefore i would point out the "best" way would probably be the "simplest" way, while at the same time then pointing out other ways of achieving an end goal - in this manner, she would i feel get an immediate benefit of an easy win, and a learning opportunity to improve techniques

Colin

 
Whooh… thats a lot of helpful tips and information!!! Overwhelming… i will try all your suggestion and see whats best for my app guys… Mike i love the gif icon… it all because of you that learning is really fun… i hope i could meet you in person and talk to you longer… i would never sleep for i know i will have a lot of learnings from all of you…

Thank you so much Griff, Mike, Colin, and myearwood… and to everyone here…
 
I feel that I have to answer.

No One solution, no matter how good, will suit every situation - whether you are talking Engineering or software development ( I was for my troubles and aeronautical engineer for many years before taking up software development )

A lump of steel for example may be ideal for a brace in a road bridge , but pretty useless in an aircraft wing

We do not really know whether Mandy is trying to build a bridge or an aeroplane hence we try to offer different solutions to the problems encountered

Also myearwood you always forget the most important people in computer software - Our Users, they are the ones who pay our wages and should be listened to, after all we are trying to interpret real world problems and come up with digital solutions for them, yes they can be guided by our suggestions, but at the end of the day, they know the issues they face and they have preferences about what user interface they see and use.

You may not like a "silly little icon" - but some users may prefer this to your talk / notify suggestion which would just have numbers incrementing in the graphical status bar ( oh and you forgot the importance of set odometer and also the need to have the graphical status bar on - and that is not always a given )- so perhaps you should realise that the time has come to accept your own fallibility, be a little more humble and accept that you do not have a monopoly on being right all the time.

learning is a never ending process - time you learnt some manners too.

To everyone else - sorry for this, but for months I have bitten my tongue.

Thanks to everyone for what i learn on here


 
I really dont know what to say... you are all giving very good tips and as ive said all of you here is making me feel that learning is so much fun... for me you are all kind and good... all your tips and suggestions are being studied by me... i am really happy that i am in this forum because you are all willing to extend your help... God bless everyone...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top