I am looking for some assistance in a VFE form where the user is entering the height and weight. I would like the BMI to then calculate and text translate.
I feel like I have the BMI calculating via a data display using a MEL expression but for some reason I cannot then get it to text translate.
Any ideas are appreciated.
Thanks
You should just be able to put a translation on the Data Display field (they don't do a translation by default when using a MEL Expression connection):
{CFMT(OBSNOW("BMI"), "", "BMI: ", "B", "
")}
Hi David,
Thanks for the suggestion, I think I have done that already but must have something odd going on. I feel like it must be that I have not told it to be "BMI" anywhere but I am not quite sure how to make that happen.
I created a data display field and in each tab below I added these items, I think I am calculating it but not actually storing it.
Options Tab:
Mel Expression
{If (OBSNOW("WEIGHT")=="" OR OBSNOW("HEIGHT")=="") then ""
else
(OBSNOW("WEIGHT")/2.2)/((OBSNOW("HEIGHT")/39.4)^2)
endif}
Translation Tab:
{CFMT(OBSNOW("BMI"), "", "BMI: ", "B", "
")}
Thanks!!!
You are exactly right, you didn't tell it to "BMI" anywhere :-). Your line where you do the BMI calc should be:
OBSNOW("BMI",(OBSNOW("WEIGHT")/2.2)/((OBSNOW("HEIGHT")/39.4)^2))
Hopefully that will do the trick. And actually, you could put all that code as a watcher in the Function View and your Data Display would just be OBSNOW("BMI").
Hi David,
Thanks for the suggestion, I am not sure what I am doing wrong but I cannot get this to display no matter what I try adding. If I add the code to write to the obsnow BMI I get compiler errors no matter where or how I add it.
I am not familiar with creating a watcher function, I did check the VFE help file and there are references to this scenario for a watcher function but I just cannot get it to work.
Is there an easy way to add the code there and then as you said just display the BMI with text translation in my data display field?
Thanks for your help and patience!!
Here's a simple BMI Example that displays BMI.
Here's what I ended up with in the Function View:
{!If (OBSNOW("WEIGHT")=="" OR OBSANY("HEIGHT")=="") then ""
else
OBSNOW("BMI",str((OBSNOW("WEIGHT")/2.2)/((OBSANY("HEIGHT")/39.4)^2)))
endif}
Forgot we need to wrap the calculation for BMI in a str() function to turn that number into a string for the obs term and i use obsany for height as this sample form defaults the previous height and if no change is made to it, it doesn't register as an OBSNOW. Weight isn't defaulted.
I would have never figured that out - thank you so very much for your patience and assistance!!!!