"jamiethehutt" <jamie / annforfungi.co.uk> writes:

> I'm trying to make a percentage progress bar for an XMMS web interface,
> I want to take the total track time and the elapsed time and then make
> a length for the bar from the percentage completed.
>
> something like:
>
> totalbarsize = 180
> timeelapsed = 10
> totaltime = 30
>
> percomplete = 0.0
> barlength = 0.0
>
> percomplete = timeelapsed / totaltime

This is an integer-division, and since totaltime is always bigger than
timeelapsed (in theory ;-) it is always 0.
You could try defining totaltime as 30.0 initially or write it as
percomplete = timeelapsed.to_f / totaltime
or something.

> barlength =  totalbarsize*percomplete
>
> puts barlength
>
> Now that should give me a barlength of 60 pixels but it gives 0
> instead. Anyone know what I'm doing wrong?
>
> Thanks!

Tom