Yes.

You can store the function (also called a UDF - User Defined Function) in an external file, or in your main file.

If for example you store the function in an external file called "MapPrinter.UDF" you would call the file at the start of your script to load the function:
Code:
CALL "\\server\path-to-files\MapPrinter.udf"



Now you can call the function as many times as you like:
Code:
If InGroup("Group1)

MapPrinter("\\server\printer1")
MapPrinter("\\Server\printer2")
EndIf
If InGroup("Groupx)
MapPrinter("\\server\printer2")
EndIf



Alternatively, just add the function to the end of your main script and call it in the same way.

Search the UDF forum for some more robust printer mapping UDFs, and have a look at the FAQ forum for information on how to use UDFs in your own scrips.