At Fri, 6 Mar 2009 10:35:00 -0500
Damien Rajon wrote:

> Hey,
> 
> You could do:
> netwidget_up = widget({ type = 'textbox', name = 'netwidget_up', align
> = 'right' })
> wicked.register(netwidget_up, wicked.widgets.net,
>   function ()
>     if ${ppp0 up_kb} < 10 then
>       return "000" . ${ppp0 up_kb}
>     end
>     if ${ppp0 up_kb} < 100 then
>       return "00" . ${ppp0 up_kb}
>     end
>     if ${ppp0 up_kb} < 1000 then
>       return "0" . ${ppp0 up_kb}
>     end
>   end  , nil, nil, 3)
> 
> I am not sure the syntax is OK (I am at work I have no way to check),
> but you've got the idea :)
> 
> Cheers,
> 
> ps: You might also want to use math.ceil(${ppp0 up_kb) for instance,
> to keep only the interger part of the number.
> 

Ugly :) Better use 

function ()
    return string.format("%04d", ${ppp0 up_kb})
end

-- 
GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o--
K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+
e- h! r y+

    Gregor Best

Attachment: signature.asc
Description: PGP signature

Reply via email to