I have a problem that I am hoping someone who is smarter then myself can help me with.
I have this bit of code that I am trying to get to work.
SUB ShowProgressBar (FileCount%, NCount%, BarWidth%, BarRow%, BarColum%)
percent = int((Ncount% / FileCount%) * 100)
Locate BarRow%, BarColumn%
Print String$(BarWidth%, Chr$(177))
Locate BarRow%, BarColumn%
Print String$((BarWidth% / 100 * percent), Chr$(178))
Locate BarRow%, (BarColumn% + 12)
Print percent + "%"
What I am trying to do is to show in screen 0 a text progress bar.
So first I would print to the screen ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ (for the background) and then the idea is to fill the progress bar with ▓ until the processing is completed.
What I can not get to work is the actual math of the progress bar.
What I am using this on is a function that reads in a CSV file and creates an ISAM database from it (so it can have anything from 0 to 10,000,000 records or more).
If someone could help me with this it would be most appreciated as I have spent the whole weekend on this and still can not get it to work correctly. I get overflow errors or the progress bar goes over 8-10 lines on screen.
Thank you for any help you can offer.
You only have 80 columns to work with on screen 0. If
BarWidth% > 80
, you will see problems.Adjust things however you want, but this should mostly do what you want:
Also, a general tip: try to multiply things before dividing to avoid rounding errors. This is not always possible, but it is a good idea to take advantage of the opportunity when you can.
Since you mentioned overflow errors, you may want to switch from 16-bit integers with the
%
suffix to 32-bit long integers with the&
suffix:FileCount%
→FileCount&
NCount%
→NCount&