You can probably do what you want using the doc_add_callback() function to attach your function as an event listener for documents. In particular, the "create" callback is probably most useful in this instance.
If you look in the online help, it has pretty good information on how to use callbacks. Look for the page on the doc_add_callback function (help 148 on the command line), and the general page on callback functions (help 762).
You can put the doc_add_callback() instruction in one of your startup ACL files. See Startup command files in the online help (help 5716).
Basically, to put it in a nutshell, you'll have something like this:
in one of your startup script files, either in your custom/init directory, or your doctype directory (if you only want it to apply to certain doctypes--in which case you'll also need to change the first parameter as described in the help). See the "Startup command files" help page cited above for help deciding where you should put this code.
Let me add one caution here. The create callback is called whenever the software creates the in memory structures for a document, not when creating the disk file. As the software opens up various files, such as the stylesheet just to name one, you may find the create callback being called much more often than you were expecting. Just make sure that your function gracefully handles the situation where it is called on additional files, not just the one where you want to add the PI. You probably want to check the top tag of the document just created to make sure that it is yours before you do the insert. John Dreystadt Software Development Director Arbortext - PTC 734-327-6079 -