General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

  • russurquhart1

    Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

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

    Hi,

    We have an old xft, that i think still works in Xmetal 6.0. When trying to run this i get an error, both on Xmetal 8.0 and now Xmetal 10.0. I've been given the Xmetal Developer tool, and am trying to debug this xft. I installed MVS 2015, then Developer 9.0, and when i start it up, i can open the .xft file, and look at the source, but my question is, how do i get started debugging the code in the xft?

    fwiw, the error when the form starts is an ActiveDocument is invalid. (Did this change between Xmetal 6.0 and Xmetal 8.0?)

    Thanks for any help!

    Russ

    Reply

    Derek Read

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    It sounds like XMetaL Author is not registered as a COM server on your machine. This is done during installation, so presumably something stopped that from happening. If that is the case then you would get the same kind of error if you run a simple macro like this:

    //XMetaL Script Language JScript:
    Application.Alert("hello");

    Before you mess around changing the XFT I would do the following on a computer where the entire customization is present (DTD, CSS, CTM, XFT, etc):

    1. Make sure XMetaL Author is not running. If it is, shut it down.
    2. At a Windows Command prompt (CMD) CD into the folder containing your XMetaL Author installation (xmetal90.exe).
    3. Run the following command: xmetal90.exe /regserver
    Note: there is no feedback.
    4. Test the customization as usual.

    Reply

    russurquhart1

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    Hi Derek,

    I just tried your suggestion on Xmetal 10.0, and it seemed to have no effect! fwiw, here is the contents of the xft that gets executed on the OnInnitialize event. I gen an error starting with  the third line and any line that references the ActiveDocument.

    function TheView_OnInitialize(){

    if (curView != 1)
    {
    ActiveDocument.ViewType=1;
    }

    // Return to start of document and get all target values
    docRange.MoveToDocumentStart();
    var nextFound = docRange.MoveToElement ();
    while (nextFound)
    {
    if (docRange.hasAttribute(“Target”))
    {
    if (docRange.ContainerAttribute(“Target”) != “”)
    {
    // store value of Target attribute
    tVal[tI] = docRange.ContainerAttribute(“Target”);
    tI = tI + 1;
    }
    }
    if (docRange.ElementName(0)== “CrossReference”)
    {
    if (docRange.ContainerAttribute(“href”) != “”)
    { // select the current element & store href val and location
    hrefVal[hrefI] = docRange.ContainerAttribute(“href”).substring(1);
    hrefLoc[hrefI] = docRange.ContainerNode;
    hrefI = hrefI + 1;
    }
    }
    //move to next element
            nextFound = docRange.MoveToElement();
    }
    findMissing();
    if (!hrefMiss)
    {
    Application.Alert(“No missing target values for cross references found.”);
    TheView.Cancel();
    ActiveDocument.ViewType = curView;
    }

    This javascript is still valid for Xmetal versions after 6.0, right?

    Reply

    Derek Read

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    Perhaps there is no document open?

    As long as Microsoft supports JScript as part of Microsoft's Windows Script Host (it is currently integral to Windows) our software will continue to support it.

    Reply

    Derek Read

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    Please let me know how the form is being launched.
    Do you have a macro that uses the CreateFormDlg() method or is it being launched using settings in the CTM file?

    Reply

    russurquhart1

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    There is a menu item:

    // Add itesm to the sub menu
    btn = btnMenu.Controls.Add (sqcbcTypePopup,-1, -1, “Missing Target values for CrossReference?”);
    btn.DescriptionText = “Missing Target values for CrossReference?”;
    btn.Caption = “Missing Target values for CrossReference?”;
    btn.OnAction = “FindMissingXRef”;
    btn.Enabled = true;

    And the FindMissingXRef macro is:

    // Note must be in tags on view for this to work.
    nonmodalDlg = null;
          XftCtrl = new ActiveXObject(“XF.XFTForm”);
          nonmodalDlg = XftCtrl.StartForm(“C:\Doczone\Forms\xRefErrs.xft”, 0);
    ]]>

    And the code i supplied previously is from the xRefErrs.xft file.

    Hope this helps, i am going to try and track down why certain systems seem to be able to have this macro work.

    Thanks,

    Russ

    Reply

    Derek Read

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    Launching the form this way requires you to inject any top-level objects yourself (from your script). If it every worked that code must be in there somewhere, perhaps in some previous version?

    Your code should be doing something like this:

    XftCtrl.AddTopLevelObject(“Application”, Application);

    This method of launching a form is not documented however, so I can't point you to any docs that discuss this. Perhaps the person the implemented it copied it from our DITA customization? Either way, I suggest looking at that code to see how it is implemented by our development team: do a cross-file search (hopefully you have an editor that lets you do that) for “AddTopLevelObject” in all the JS files inside the XMetaL Author Enterprise install you will find a bunch of relevant examples.

    Reply

    russurquhart1

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    Hi Derek,

    I am looking through the .js files as you suggested.

    NOTE: I'm pretty certain that this code and xft, work as is, in Xmetal 6.0. All of the users that we have, that are still using Xmetal 6, ARE able to get this macro to work.

    You had mentioned that the DITA developers has used similar code. Is it possible that something was changed under the covers in Xmetal, around or shortly after version 6.0, that changed and necessitated the AddTopLevelobject call prior to starting the form?

    In either case i found the following code seems to work:

    // Note must be in tags on view for this to work.
    nonmodalDlg = null;
          XftCtrl = new ActiveXObject(“XF.XFTForm”);
    XftCtrl.AddTopLevelObject(“Application”, Application);
    XftCtrl.AddTopLevelObject(“ActiveDocument”, ActiveDocument);
    XftCtrl.AddTopLevelObject(“Selection”, Selection);
    XftCtrl.ParentWindow(Application.WindowHandle);
          nonmodalDlg = XftCtrl.StartForm(“C:\Doczone\Forms\xRefErrs.xft”, 0);
    ]]>

    (Do you know if this is all i need to add, to regain the xft functionality?)

    If this is a nonstandard, undocumented/unsupported method to do this, what would be the correct way?

    Also, is it possible to debug inside an xft file? I had put the debugger; command inside the code of the .xft file, but it never made it to the debugger?

    Thanks again,

    Russ

    Reply

    Derek Read

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    When I said JS files I meant that the only known examples of using this method that I'm aware of are in the DITA customization, the majority of which is coded in JS files. If you are looking through your own customization it is less likely that JS files were used and that the code is in an MCR file. Our DITA customization is written in JS files as it helps with debugging (the MCR files we use load the JS files as a string then JScript “eval” to inject it into the MCR's JScript).

    It is unsupported in as much as it is undocumented (so there's no technical support for it). We generally don't expect anyone to be able to figure out how to do things that aren't documented. The documented way for launching a form from script is to use the CreateFormDlg method. The Programmers Guide lists this example:

    // XMetaL Script Language JSCRIPT:
    // Call an instance of myform.xft
    var dlg=Application.CreateFormDlg("C:\myform.xft");
    dlg.DoModal();
    dlg=null;

    If your form doesn't need to be non-modal then I'd use the CreateFormDlg() method above. However, if it must be non-modal then you will need to use the code you are using. The change you've made here should inject the Application object as “Application” so you can refer to it as such in your XFT code (you can change the object name when you pass it in, but I'd leave it as “Application”).

    You can't debug inside an XFT. That is one reason to externalize all the code. A long time ago, before we moved to the Visual Studio integration of XMetaL Developer, we had our own debugger for XFT. However, when we moved to the Visual Studio integration that had to be dropped as it was just not compatible.

    However, if you put all (or most of) the code inside your MCR file and then inject that (as you sort of seem to be doing, at least partially) then you can debug that injected code using the Microsoft debugger. The issue is that XFT is a binary format that Visual Studio can't deal with, but putting the code into a JS or MCR file allows it to load it into the debugger.

    Reply

    russurquhart1

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    Derek,

    Thanks for all the help!!

    As i'm sure someone will ask, so do you know, if the handling of xft forms, near or on version 6, when this macro was and IS still working, changed on Xmetal versions after 6.0?

    Also, is the inclusion of the AddTopLevelObject code sufficient to making this older macro work in the later versions of XMetal? i.e. is that all i need to add? I am checking to see what version they are using, and depending on the version, add the AddTopLevelObject code!

    Thanks again!

    Russ

    Reply

    Derek Read

    Reply to: Using Xmetal Developer 9.0 w/MVS 2015 to debug xft

    I'm surprised this XFT worked as written in 6.0. From my understanding of the software it shouldn't but I don't have a direct insight into the actual code that drives the XFT (this is a DLL separate from the xmetal60.exe called xfrunner.dll). Perhaps this was changed at some point but to my understanding the software wasn't designed that way (if so I don't see why we would have implemented the AddTopLevelObject method).

    Maybe it accidentally used to work in older versions, and because it was never documented someone just tried it that way and it happened to work even though it wasn't designed to.

    Reply

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

Lost Your Password?

Products
Downloads
Support