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!
Hi,
I have 6 fields where the user enters opening bank balances for 6 banks. I need to add the values of the 6 fields to determine if the total is more than zero, which indicates that at least one field is now not "Balance pending". This info is necessary for the next coding step. I have tried
yes
I was just going to say you should make sure there is no comma in the values you're trying to add (keeping in mind that the default decimal point is a period, not a comma as it is in many countries. Needless to say this only works on pure numerical values - but you probably beat me to it
The dictionary is always helpful - look up 'sum':
sum(<numbersList>)
where: numbersList is
a sequence of parameters, each a number or evaluating to a number or
CAsba wrote: Mon Dec 05, 2022 11:57 am
I get error message 'operators +: error in left operand.
Could it be because some of the fields conents are not numeric ?
Why didn't you write this important info in your posting?
What stam said, you need to check if the field contains a number.
Just for the exercise, you should do that better, so that any field that is NOT a number is flagged for you.This is best done in a loop, something like:
on mouseUp
repeat with y = 1 to the number of flds
if fld ("pg" & y) is a number then add fld ("pg" & y) to field "sum of balances"
else
answer "Field" && ("pg" & y) && "needs looking at"
exit repeat
end if
end repeat
end mouseUp