If I understand you correct, I would
a) make a script, that contains the function (with parameter that is) to do all the work.
b) include that script from the "main" script (via run('path/to/script')
c) call that function (a) with the parameters you like.