How to define a function and can be reused and called by other query

I defined a function as attached picture:
I passed the array of query name and then trigger it sequentially.
I have tested and it worked.
But I have trouble to get the query name and output to the text .
Another question how to reuse this function in other queries?

Hey Richard,

This post explains how to create reusable functions.