VS: desimal numbers calculation

Esa Kivelä Esa.Kivela at ncrc.fi
Tue Oct 15 01:53:01 EDT 2002


> -----Alkuperäinen viesti-----
> Lähettäjä: Jan Schenkel [mailto:janschenkel at yahoo.com]
> Lähetetty: 14. lokakuuta 2002 14:57
> Vastaanottaja: use-revolution at lists.runrev.com
> Aihe: Re: desimal numbers calculation
> 
> 
> --- Esa_Kivelä <Esa.Kivela at ncrc.fi> wrote:
> > Greetings
> > 
> > Some newbie question:
> > 
> > I tried to calculate desimal numbers in RR but how
> > can code some calculation. 
> >  
> > In the card I have some text filed where users put
> > some numbers like 0,5, 3,4 and so on. 
> >  
> > In some field I'd like to show those fields result
> > as ie. 0,5 + 3,4 and so on but that + operator in
> > the script won't calculate desimal numbers. 
> >  
> > Is there any other way to sum those desimal numbers?
> > 
> >  
> > Yours 
> >  
> > EsaK 
> >
> 
> Hi Esa,
> 
> RunRev expects numeric data to have a decimal point.
> Therefore, you'll have to convert between 'display'
> and 'calculation' format before and after calculation.
> If you don't need thousand separators, then it's as
> easy as:
>   function Conv4Disp pNumber
>     replace "." with "," in pNumber
>     return pNumber
>   end Conv4Disp
>   function Conv4Calc pNumber
>     replace "," with "." in pNumber
>     return pNumber
>   end Conv4Calc
> 
> Hope this helped,

More simple that that is this code. Some text field calulates others text fields desimal numbers "on the fly":

on idle
  set the itemdel to ","
  put item 1 of field "seitsemän" + item 1 of field "kahdeksan" + \
      item 1 of field "yhdeksän" + item 1 of field id 1028 + item 1 of field id 1027 \
      + item 1 of field "kaksitoista" + item 1 of field "kolmetoista" \
      + item 1 of field "neljätoista" + item 1 of field "viisitoista" \
      + item 1 of field "kuusitoista" + item 1 of field "seitsemäntoista" into field "18"
  
end idle

And itse works!

Many tahnks for help to the those who answer to my problem :-)

EsaK



More information about the use-livecode mailing list