General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Track changes default on

  • bjorn

    Track changes default on

    Participants 9
    Replies 10
    Last Activity 7 years, 8 months ago

    Hi.
    We uses XMetaL Version#: 9.0.0.053

    When we start XMetaL, we need it to default turn on track changes on startup. I'm have been looking a little bit around, and see if I could figure out where this could be set, without luck.

    Do you know if this is possible, and how could this action be be triggered?

    Thanks!

    Regards,
    Bjørn

    Reply

    barbwire

    Reply to: Track changes default on

    Create macro, which tells:
    [code]ActiveDocument.TrackRevisions = true;[/code]
    http://xmetal.com/webhelp/en/xmetaldeveloper/pg/7.0/Document-TrackRevisions.html#xmetal.pg_document.trackrevisions

    edit: put the macro to startup-folder for event which you like (maybe document open complete).

    Reply

    npalmer610

    Reply to: Track changes default on

    Hi. I'm a complete n00b to Xmetal macros, so please bear with me. I'm using Xmetal Version#: 9.0.0.053. I am trying to turn on Track Changes by default when opening files that already have tracked changes. I tried to follow the example, but I haven't the foggiest how to build it into a macro. Would anyone be kind enough to give me some guidance? I know this will ultimately go in my .mcr file, but I'm not quite certain how to construct it so that it is functional (other than knowing it needs a closing and opening tag. Thanking you in advance for your help!

    Reply

    barbwire

    Reply to: Track changes default on

    [code]
    ActiveDocument.TrackRevisions = true;
    ]]>

    [/code]
    Hope this works. v_v

    Reply

    npalmer610

    Reply to: Track changes default on

    [code]
    ActiveDocument.TrackRevisions = true;
    ]]>

    [/code]
    Hope this works. v_v

    Barbwire, those are the most beautiful lines of code I've seen all morning: this worked perfectly. Thanks so much!!! ^ _ ^

    Reply

    npalmer610

    Reply to: Track changes default on

    Barbwire, I did have one quick follow-up: is there a way to modify it so that it is only turned on by default if there are already tracked changes in the file?

    Reply

    barbwire

    Reply to: Track changes default on

    Barbwire, I did have one quick follow-up: is there a way to modify it so that it is only turned on by default if there are already tracked changes in the file?

    Well, I think it is maybe possible by modifying macro, but I don't have time to do that. 😛

    Reply

    Derek Read

    Reply to: Track changes default on

    Try something like this:

    [code]var rng = ActiveDocument.Range;
    rng.SelectAll();
    var docStr = rng.TextWithRM;
    //Application.Alert(docStr);
    var has_change_mark = false;
    if(docStr.search(/ -1) {
    has_change_mark = true;
    }
    if(docStr.search(/ -1) {
    has_change_mark = true;
    }
    if(has_change_mark) {
    ActiveDocument.TrackRevisions = true;
    }
    //else: do nothing
    ]]>
    [/code]

    Note: The code above may look odd, and it is a bit unusual. Normally there are far better ways to find content (including PIs) in a document. The APIs getNodesByXPath() and GotoNext() work for PIs and would be preferable, but specifically do [u]not[/u] find Revision Marking PIs. The nature of the Revision Marking PIs makes that impossible as they exist outside of the main content of the DOM in XMetaL (for good reasons I won't try to explain). This script grabs the document's content as a string using the special TextWithRM property (to bring in the revision marks), then examines that text using JScript regular expressions (normally something that would be pretty dumb to do on an XML string but that is “good enough” for this case, and has the added benefit of being fast). There is a special PI for moving between revision marks named GotoNextChange(), but that results in a dialog being displayed when no revision marks are found and obviously you want this script to run silently.

    Reply

    lxsibi

    Reply to: Track changes default on

    Our XML files are in a content management system, Astoria, and we use XMetaL Version#: 8.0.1.041 to edit the files. We would like to turn on track changes as the default when editing files since it is quite possible that our writers may forget to turn it on. I tried using Barbwire's code and named the file TrackChangesOn.mcr which is placed in the Startup folder. But it didn't work.

    Did I place the macro file in the wrong place, does it not work with Version 8, or do I need to place this code in another location?

    Thanks for you help.

    Reply

    Derek Read

    Reply to: Track changes default on

    It should work with any release. I can think of a few possibilities:

    1) The Astoria code is interfering with the macro. You would need to follow up with them for help in this case. Perhaps their integration also uses this API or does something to interfere with it.
    2) The macro file is not loading or some of its content is being ignored. This would suggest it is incorrectly formatted or there is some other issue with the file.
    3) The specific version you are running has a bug. I'm not aware of any bugs related to this API however.

    Reply

    barbwire

    Reply to: Track changes default on

    Our XML files are in a content management system, Astoria, and we use XMetaL Version#: 8.0.1.041 to edit the files. We would like to turn on track changes as the default when editing files since it is quite possible that our writers may forget to turn it on. I tried using Barbwire's code and named the file TrackChangesOn.mcr which is placed in the Startup folder. But it didn't work.

    Did I place the macro file in the wrong place, does it not work with Version 8, or do I need to place this code in another location?

    Thanks for you help.

    Did you remember to put doctype and ?:
    [code]



    ActiveDocument.TrackRevisions = true;
    ]]>


    [/code]

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support