I wrote an article quite awhile back, it's at this link.
caveat; I don't know if it requires a subscription or not.
If you download the code there is a source member called wsrc_f.
In there is a procedure called #compile which does exactly what
(I think) you're looking for. You should be able to pluck it out
and put it wherever you want.
This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact