Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
i have two fields. in these two fields i type in some numbers. then i have a button. the script of the button should multiply the numbers of the fields. what am i doing wrong? do i have to tell the app that the fields contain numbers? if yes, please how
As bernd suggests, this error indicates that the contents of field "Felda" is not a number. (Perhaps using a comma as a decimal separator, where LC needs a point. Or, if you have a field with a single line height, someone has entered a value, then hit the return key, so the field looks empty, then a new value is typed in the field. Or something else has happened to put other content into the field so the multiplication operator cannot interpret the first value as a number.)
You need to validate the contents in order to ensure a genuine mathematical operation can be performed.
function ohnekomma tNumber
## ohne komma = german for: without comma
replace COMMA with "." in tNumber
return tNumber
end ohnekomma
function mitkomma tNumber
## with komma = german for: with comma
replace "." with COMMA in tNumber
return tNumber
end mitkomma
Then use them before computing and again before dispklaying to german users:
...
put fld "a decimal number in german" into tFa
put fld "another decimal number in german" into tFb
## Before computing:
put ohnekomma(tFa) intoi tFa
put ohnekomma(tFb) into tFb
## Now compoute witn english numbers
put tFa * tFb into tResult
## "convert" back to german before displaying
put mitkomma(tResult) into fld "ergebnis"
...