The following are various forms of Function definitions you can use in COD scripts. In most cases, the syntax can be copied/pasted directly into a file and function properly. They should be edited for your particular use. This allows you to short cut your time by not having to experiment to figure out code syntax.

TypeExample
Named Function
function myfun()
Debug "Test Function"
end function
Named Function with Argument
function myfun(arg)
debug arg
end function
myfun("Test Function")
Named Function with Return Value
function myfun()
return 2 * 2
end function
dim myvar
myvar = myfun()
Named Function with Return Value and Argument
function myfun(arg)
return arg * arg
end function
dim myvar
myvar = myfun(2)