Categories > TinyButStrong general >

number format ha a ca

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: elyoukey
Date: 2005-04-05
Time: 14:43

number format ha a ca

hello,
i am a newbie with TBS, and i am searching the way to transform
490610
in
49ha06a10ca

i think i must use
[var.myvar;frm='????']
but what do i have to put inthe ???? ?

thanks
By: Skrol29
Date: 2005-04-05
Time: 15:45

Re: number format ha a ca

Hi Elyoukey,

490610 cannot be interpreted as a time representation by TBS.
You have to write your own formating function and use it with parameter 'onformat'.
By: elyoukey
Date: 2005-04-06
Time: 09:13

Re: number format ha a ca

thanks,
but now i wonder how does it work, i found the way to put the function :

function surface($champ,&$CurrVal){...}
but where can i find the value of $champ ?
it shows
var.tab.surface1

...?
By: elyoukey
Date: 2005-04-06
Time: 09:42

Re: number format ha a ca

autoreply :
here is the function (for people who are searching such a thing) :

//fonction de formattage en surface ha a ca
function surface($champ,&$CurrVal){
       
        $chiffre = $CurrVal;
        $ha=$a=$ca=$result="";
        $tay=strlen($chiffre);

        for( $i = 0 ; $i<= $tay-5 ; $i++){
        $ha .= $chiffre[$i]."";
        }

        if($ha != "")
        {$result.=$ha."ha";}

        $a=$chiffre[$tay-4].$chiffre[$tay-3];
        if($a != "")
        {$result.=$a."a";}

        $ca=$chiffre[$tay-2].$chiffre[$tay-1];
        if($ca != "")
        {$result.=$ca."ca";}

        $CurrVal= $result;
       
}       

and it works with that :
[var.tab.Surface1;onformat='surface']

thanks ^_^