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.