Error Trap
Posted: Mon Jan 28, 2019 12:07 pm
2nd Post (Yay)
I'm making a BMI calculation app and I'm trying to trap a possible error where the user does not enter anything into the input fields, and when the height is zero(as BMI is weight divided by height squared and you can't divide by zero). The following code is for the calculation button where I'm trying to trap the errors spoken above where "bmiField" is the final output field. For some reason, always get an error at the duo of "put" lines. What's wrong with it?
global x
on mouseUp
if text of field "heightField" is not "0" or field "heightField" is not empty or field "weightField" is not empty then
put field("heightField") * field("heightField") into x
put field("weightField") / x into field "bmiField"
else
put("Enter proper height please.") into field "bmiField"
end if
end mouseUp
I'm making a BMI calculation app and I'm trying to trap a possible error where the user does not enter anything into the input fields, and when the height is zero(as BMI is weight divided by height squared and you can't divide by zero). The following code is for the calculation button where I'm trying to trap the errors spoken above where "bmiField" is the final output field. For some reason, always get an error at the duo of "put" lines. What's wrong with it?
global x
on mouseUp
if text of field "heightField" is not "0" or field "heightField" is not empty or field "weightField" is not empty then
put field("heightField") * field("heightField") into x
put field("weightField") / x into field "bmiField"
else
put("Enter proper height please.") into field "bmiField"
end if
end mouseUp