I have tried using this:
Action Buttom -> Calculate
{OBSNOW("Weight") / ( OBSNOW("Height") * OBSNOW("Height") ) * 703}
but doesn't work, can someone help. Thanks.
observations are stored as strings, try this to convert the strings to values
{val(OBSNOW("Weight")) / ( val(OBSNOW("Height")) * val(OBSNOW("Height")) ) * 703}
or you could use this function
{fn CalcBMIConv(heightnow,heightprev,weightnow) {
local heightval = ""
cond
case heightnow <> ""
heightval = heightnow
case heightprev <> ""
heightval = heightprev
else
heightval = ""
endcond
if weightnow == "" or heightval == "" or val(weightnow) == 0 or val(heightval) == 0 then
return ""
endif
if heightval == 0 then
return str(0)
endif
return str((weightnow / 2.2) / ((heightval / 39.4)^2))
}}
Thanks, worked.
acantu said:
Thanks, worked.
I know this is answered already but here's a shorter version that is setup in the whiteboard area...
{fn CalcBMI(){
IF (OBSNOW("WEIGHT") == "" OR OBSNOW("HEIGHT") == "") THEN
return ""
ENDIF
return round((OBSNOW("WEIGHT") / 2.2046) / ((OBSNOW("HEIGHT") / 39.3701) ^2),2)
}}
Thanks, but why is it when i try to assign this to a button, i get the following error:
"Internal or unpaired braces are not allowed in the calculation expression. Please correct."
set the field to RUNPROCESS
gibsonmi said:
set the field to RUNPROCESS
Now i get
"You cannot use brackets or carriage returns in the highlighted field. Please correct."
Nevermind, got it working. Thanks.