I am new at writing MEL code (but not code in general) and I wrote a simple if statement on our patient pin letter and I noticed that it would put the word FALSE on the letter if the if statement was not true. Likewise, my userok would print the word FALSE on the page. I ended up having to put double quotes after the userok and add an else statement that only consisted of "". Is this normal behavior or should I have written something differently.
Here is the code:
{
global sExp
global sDur
sExp = ADDDATES(str(LAST_SIGNED_OBS_DATE("PATPORTALPIN")), "0","0","30")
sDur = DURATIONDAYS(str(._TODAYSDATE), sExp)
global iDur = val(sDur)
If iDur < 0 Then
userok("THIS PIN HAS EXPIRED. PLEASE CREATE A NEW ONE BEFORE PRINTING THIS LETTER")
""
else
""
endif
}
Yes, for MEL an IF statement requires an ELSE statement. Even if it is blank or it will return FALSE as you are seeing. It's something that I have to remember when writing MEL because other languages don't require it.
Hope that helps!
Thank you. I tried to find some reference to this rule in the manual I was given but I didn't. It looks like the manual was written in 2004 so perhaps I should go look for a new one.