Hi Everyone,
It's been a few year since I thought about any MEL related things and now I'm stuck and looking for help!
I have a form to record result values and enter when the test is next due (dropdown with intervals). I tried making a function with a case condition but I'm missing a piece and for the life of me I can't figure out what it is. I'm calling the function with a button:
{fnnextdate(DOCUMENT.Nextdue,"Obs Name")}
{fn fnnextdate(due,obs) {
local duedate = ""
duedate = (cond
case due == "3 mo" return ADDDATES(str(._TODAYSDATE),0,3,0)
case due == "6 mo" return ADDDATES(str(._TODAYSDATE),0,6,0)
case due == "1 yr" return ADDDATES(str(._TODAYSDATE),1,0,0)
case due == "2 yr" return ADDDATES(str(._TODAYSDATE),2,0,0)
case due == "3 yr" return ADDDATES(str(._TODAYSDATE),3,0,0)
case due == "5 yr" return ADDDATES(str(._TODAYSDATE),5,0,0)
case due == "10 yr" return ADDDATES(str(._TODAYSDATE),10,0,0)
else ""
endcond)
OBSNOW(obs,duedate,str(._TODAYSDATE))
end
}
}
I'm also open to recommendations on alternatives to do this. I need to determine the next dates for about a dozen tests.
Thanks!
Think about the keyword 'return'. It is used to exit the function, hence if a condition is met, the latter code is never executed. Instead, use a local variable to store the value for the case statement. You almost had it, replace the 'return' with 'duedate = ' and you should be fine. Also, delete the 'end' statement, it is not used in MEL proper and probably will cause issues. Instead, if you are not returning an actual value to a variable outside of the function, use 'return "" ' to avoid having a result printed in the chart note.