i am writing my own program.
in that program among many other functions, i have two which are important here:
first one to copy multiple files from one location to another,
and second one to erase original files.
both of those functions have progress bar, which displays how moch percent is finished.
when copying files, it is easy.
two subfunctions count the number of files in new directory, and in original directory.
third one function compares those two numbers and returns percentage.
and fourth subfunction displays progress bar which is "filled" acording to returned percentage by the third subfunction.
the problem is when i use those subfunctions on function for deleting original files.
it appears that returned percentage is at the beggining 100%, and at the end 0%, so, my progress bar acctually goes from end to beggining.
i know why that is, because there is less and less files in the original directory, so the difference in number of files betwean original directory and the new directory is bigger and bigger.
i know that, but because of that my subfunctions returns inverted percentage from wanted.
i am planning to add one new subfunction betwean third and fourth one which would invert the percentage.
by inverting percentage i mean, when i have 0%, that function return 100%, when for example 49% to return 51% and so on.
this is wery easy problem, and i do not want any program code as an answer, just an mathematical formula which invert percentage, and i will turn it in the program code on my own.
for now, all i can think of is an manual percentage inverting subfunction, so like, "if /i "%percentage%" equ "100" set percentage=0" and so on untill "if /i "%percentage%" equ "0" set percentage=100", but i do not want to manually do this, because, i do not want to write 100 lines of program code if there is no need. i would prefer just one line of program code in this subfunction in the form of formula. (so like c=a+b or something.)
so, what i want you to do, is to tell mi an mathematical formula which will invert percentage.
i will start, and you finish it.
thank you for your time. :)
it is so nice to have a place to write my own problems with computer programs.