Writing functions in vimrc is quite straight-forward. The keyword is actually:
function!
and ends with endfunction
function! HelloWorld(param1, param2)
echo 'using param1: ' . a:param1
echo 'using param2: ' . a:param2
return 0
endfunction
" calling the function
call HelloWorld(expand('%:p'), expand('%p:h'))