And yes, your understanding of how the GetDefaultPrinter function is working is correct. UDF is short of User Defined Function. You can define whatever you want in UDFs at the bottom, or top of you script, and the kix executable will recognize these when it loads the script.

In this case, since the the UDF is only being called once, we really could have just put that single line of code towards the top, and not bothered with a UDF. But that's kind of the beauty of UDFs, they are made to be universal and plug n play, callable from anywhere in the code regardless of what the rest of the script contains.