Jump to content
Sign in to follow this  
ileandros

Math help calculate percentage

Recommended Posts

ileandros

Hello,

As the tittle says i need some math help to calculate percentage.

This is my script

#include <GUIConstantsEx.au3>
$s = 58985480
$ts = Round($s / 1000)
$ds = 57603
$i = 0
Do
    $sec = @SEC
    $bs = 1500
    While @SEC = $sec
    WEnd
    $cs = $ds
 $ts = Round($ts - (($cs - $bs) /100))
 $ps = Round($ts / $s * 100000)
    ConsoleWrite($ts & @CRLF & $ps &"%" & @CRLF)
Until $i = 100

$ps is the percentage. What the script does is: It has a specific number and every sec that number gets lowered.

I have managed getting it percentage and count it but my problem is that is the wrong way.

It has to rise from 0% to 100%. Now it is the oposite. It is 100% and as the number gets lowered it gets too.

Any kind of help appretiated


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
AdmiralAlkex

What if you do

$ps = 100 - $ps

before the ConsoleWrite()? That would make it count up.

I would also add a Sleep() at least in the while-loop to make it less resource hungry.

Share this post


Link to post
Share on other sites
ileandros

Hell yes!

You know dude? When mind gets stuck, that means i need a beer :D

The problem with sleep add is that is would change the diff from 1 sec to 1,1 and that would change my entire script after some seconds or minutes


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
AdmiralAlkex

I assume there's a timer or something somewhere then? Because in what you posted above you only use seconds so a few (or hundreds) of milliseconds wouldn't make any difference.

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites
ileandros

Yes there is. And it could run for minutes or even hours. Anyway i added 10ms sleep.

Saw the script running better after a while :D

Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×