Page 1 of 1

Adding fields with £ signs

Posted: Mon Mar 22, 2010 9:23 pm
by bsouthuk
Wonder if someone can help.

I'm working on a commission calculator and want certain fields with numbers in them to show the £ sign. The problem is, I use the fields with £ signs to + and subtract with other fields with £ signs and when I get a coding error which I assume is because Rev sees the £ sign as not a digit!

How do I get around this?

Cheers

Dan

Re: Adding fields with £ signs

Posted: Mon Mar 22, 2010 11:38 pm
by RRobert
Hello Dan,

why you do not add and remove the british pound sign before you do the calculation?

Robert

Re: Adding fields with £ signs

Posted: Mon Mar 22, 2010 11:49 pm
by bsouthuk
I have tried this using code:

Code: Select all

put "£" & field "A" + field "B" into field "C"
However, I then have to use field C to + to field D but as the £ is in field C I get a coding error

Re: Adding fields with £ signs

Posted: Mon Mar 22, 2010 11:56 pm
by bn
Dan,
you could take out the £ sign temporarily.

Code: Select all

put field "x" into tData
replace "£" with empty in tData
put tData + tWhatToAdd into tData
put "£" && tdata into field "result"
regards
Bernd

Re: Adding fields with £ signs

Posted: Tue Mar 23, 2010 2:34 pm
by dunbarx
It might be easier to manage if you use a function when this arises:

Code: Select all

function goodNumber tText
   repeat for each char theChar in tText
      if theChar is in ".0123456789" then put theChar after temp
   end repeat
   return temp
end goodNumber
So you can say get "£" & goodNumber(firstData) + goodNumber(secondData).

This makes sure that ANY errant character that might hang rev up is eliminated. I get these now and then due to typos, some of which are invisible.

Craig Newman

Re: Adding fields with £ signs

Posted: Tue Mar 23, 2010 2:51 pm
by bsouthuk
That seems are better way thank you Craig.

Are you saying to place this script in the stact script, therefore whenever there is a £ sign in fields that are involved in calculations with other fields that have the £ sign then the stack script will mitigate any code errors and the £ sign will be ignored?

Cheers

Dan