Page 1 of 1

Operators *: error in left operand

Posted: Tue Feb 10, 2015 8:30 pm
by jalz
Hey all,

I'm having trouble with the following line of code. Its says (Operators *: error in left operand), char 12. field fld_rate contains values like $ 1,250.50 and field hours could have 5.5. I'm using the function bn suggested in my last threadhttp://forums.livecode.com/viewtopic.php?f=7&t=22898 to remove special characters and return the result so I can perform this multiplication.

Thanks as always

Code: Select all

put (accountancyFormatRemove(field "fld_rate")) * (accountancyFormatRemove(field "fld_hours")) into tCost

Re: Operators *: error in left operand

Posted: Tue Feb 10, 2015 8:49 pm
by dunbarx
Hi.

Well, what happens if you test each operand in some way, like:

Code: Select all

answer (accountancyFormatRemove(field "fld_rate")) is a number
That sort of thing.

If you want a validating gadget, then whatever Bernd offered is obviously fine. I wrote a function in about 1989 that strips all chars but "0-9" and the decimal point. Likely everyone on the planet has written something similar. I have it loaded as a library handler. It is not rocket science, but:

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
Craig

Re: Operators *: error in left operand

Posted: Tue Feb 10, 2015 9:20 pm
by jalz
Hi Craig,

Thanks, I seem to make things more complicated then they have to be. Dont know why. The line of code you posted earlier (below) producing false so I guess the function isn't quite stripping out everything I was expecting. Thanks for the snippet of info.

Code: Select all

 answer (accountancyFormatRemove(field "fld_rate")) is a number 

Re: Operators *: error in left operand

Posted: Tue Feb 10, 2015 9:28 pm
by dunbarx
Better than what I do, which is to make things sillier than they have to be.

Craig