You can do this with a pretty simple doc callback. Callbacks let you respond to particular events. In this case, the insertion of a comment tag is the event you want to respond to. Put this code somewhere in your init ACL file:
function insert_tag_after_callback(doc, tagname, oid, op) {
Looks like there may have been changes to call-back functions in AE after ver 5.3.
I got following error when I tried your code as is in my AE 5.3 M110:
Wrong number of arguments to insert_tag_after_callback(): 3 passed, 4 expected (at line 93 of file "C:\Program Files\Arbortext\Editor\packages\main\_docev.acl")
I checked AE 5.3 help for insert_tag_after callback type [help 148] and saw it had this function prototype: funcname (doc, tagname, op)
So I changed the function to have 3 parameters (no "oid") as follows and it now works as advertised:
function insert_tag_after_callback(doc, tagname, op) { if (op==1) { return 0; } if (tagname == "_comment") { insert("[" . username() . "]: "); } }
Thanks for the clarification, Jack. My projects tend to use current releases of Arbortext, so that's usually what I test against, and sometimes I forget that there are folks out there still using older versions.
According to the documentation, all the fields of the time_date() function are fixed width, so you should just be able to take a fixed substring, like this: