Hi. I am wondering why the following will not return the value from the first set of if statements.
If OSWESTRY 1 is populated, say, value 5, the result for score does not populate in the form. However, if I populate OSWESTRY 2 ( second set of statements), then the sum is returned.
Not sure why it won't return a result if just the first term is populated. Any ideas ?
Thanks... John
{!fn fnscore() {
local summ1 = ""
local summ2 = ""
local score = ""
if match(sub(obsnow("OSWESTRY 1"),1,1),"0")>0 then summ1 = "0" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"1")>0 then summ1 = "1" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"2")>0 then summ1 = "2" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"3")>0 then summ1 = "3" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"4")>0 then summ1 = "4" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"5")>0 then summ1 = "5" else "" endif
if summ1 "" then score = val(summ1) else score = 0 endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"0")>0 then summ2 = "0" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"1")>0 then summ2 = "1" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"2")>0 then summ2 = "2" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"3")>0 then summ2 = "3" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"4")>0 then summ2 = "4" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"5")>0 then summ2 = "5" else "" endif
if summ2 "" then score = score + val(summ2) else "" endif
return score
}}
The last if statements on summ1 and summ2 both show this :
- if summ1 "" then
I think you would need to say something like this:
- if summ1 <> "" then
I also just noticed all your numbers have a double quote then the number then a single quote ex: "0' You may have to change it to double quote then the number then double quote ex: "0"
All quotes seem to be fine.
{!fn fnscore() {
local summ1 = ""
local summ2 = ""
local score = ""
OBSNOW("HEIGHT","33")
if match(sub(obsnow("OSWESTRY 1"),1,1),"0")>0 then summ1 = "0" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"1")>0 then summ1 = "1" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"2")>0 then summ1 = "2" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"3")>0 then summ1 = "3" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"4")>0 then summ1 = "4" else "" endif
if match(sub(obsnow("OSWESTRY 1"),1,1),"5")>0 then summ1 = "5" else "" endif
if summ1"" then score = val(summ1) else "" endif
score = val(summ1)
if match(sub(obsnow("OSWESTRY 2"),1,1),"0")>0 then summ2 = "0" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"1")>0 then summ2 = "1" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"2")>0 then summ2 = "2" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"3")>0 then summ2 = "3" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"4")>0 then summ2 = "4" else "" endif
if match(sub(obsnow("OSWESTRY 2"),1,1),"5")>0 then summ2 = "5" else "" endif
if summ2"" then score = score + val(summ2) else "" endif
return score
}}
Still, if I just enter a value for OSWESTRY 1, the score does not show. Very odd.
You still have summ1 "" and summ2 "" at the end on each part of the function:
if summ1"" then score = val(summ1) else "" endif
Replace this with:
if summ1 <> "" then score = val(summ1) else "" endif
Do the same for summ2.
There is a not equal to symbol. For some reason, cutting and pasting here did not show it, but it is there.