I'm sorry not to understand what you mean buy "this is not an UDF", that i have to "strip it down to UDF" (I'm french !). Please explain me with more details.
And for the header, the link to use the correct header does not work. I've rebuilt the header to be more close of what is recommended.