Archive: Math plugin help


Math plugin help
Hello all.

Well I made a little nsis script to read all txt files in a folder, inspecting them based on some criteria. This works just fine. The inspection process takes place in a function, and therefore the progress bar does not accurately display the true progress of the script.

What I would like to do is use Stu's RealProgress plug-in to manually set the progress bar. My strategy (feel free to offer up an alternative) is to get then number of files in the folder, say 250, then divide by 100, giving me 2.5 in this case.

Then after checking each file, I do this:

(after 1 file checked)
$NumFilesChecked/2.5 = .4 --> rounded = $CurrentProgress
RealProgress::SetProgress /NOUNLOAD $CurrentProgress

(after 2 files checked)
$NumFilesChecked/2.5 = .8 --> rounded = $CurrentProgress
RealProgress::SetProgress /NOUNLOAD $CurrentProgress

(after 3 files checked)
$NumFilesChecked/2.5 = 1.2 --> rounded = $CurrentProgress
RealProgress::SetProgress /NOUNLOAD $CurrentProgress

Ok, so you get it right. If this is an acceptable strategy for manually setting the RealProgress bar, I just need the syntax for using the Math Plug-in to do decimal division, and rounding (separately).

I have searched like crazy, but just can't seem to understand the math::script usage, can you help me? Thanks all for looking.

Jnuw


$CurrentFile / $TotalFiles * 100

Progress bar value should be out of 100, i.e. a percentage figure with no decimal point.

-Stu


Hi Stu, your right, that makes more sense. But I'm still going to need the math plugin for that right, otherwise with IntOp I'll lose the decimals: (IntOp $0 2 / 250 ) equals 0, when it really is .008 right?

Can I get the syntax for the math plug in to do that division, multiplication, and rounding? Or am I still missing something? Thanks so much for your help.


I would question whether or not the decimal numbers really matter with a progress bar. As long as you are relatively close, it will still give the end user a relative idea of how far into a process your install really is.

If you still decide you need to do floating point operations, you might take a look at the this floating op plugin.


Thanks guys, got it to work!