General XMetaL Discussion

  • ghkrause

    XMAX and XFT via CTM

    Participants 1
    Replies 2
    Last Activity 14 years ago

    We use XMetaL Author EE 5.1 and XMAX 5.1.
    We use XFT files via in CTM file successfully in both applications.
    We want to trigger an XFT form when a specific element is inserted and got this running with XMetaL Author using this code in CTM file:

      [..]
     
       
          q-physicalsymbol
          JScript
         
                      Selection.InsertElement( “q-physicalsymbol” );
              var dlg = ActiveDocument.Host.CreateFormDlg( “q-physicalsymbol.xft”, ActiveDocument.Range.ContainerNode );
              dlg.DoModal( );
              dlg = null;
            ]]>
         

       

     


    Note: The XFT file needs to be located in Application.Path of XMetaL Author to be opened successfully.
    This code triggers an errors in XMAX:
      XFRunner: Can not open file “q-physicalsymbol.xft”.
      Run-Time Error: Line 4, Column 10, Description: 'dlg' is null or not an object
    The XFT file is part of the XAC file created for XMAX.
    The same XFT file opens fine in XMAX for exisiting elements via  .
    You may already guess my question: Where to place the XFT file or how to address the XFT file.
    Your help is appreciated.

    Reply

    Derek Read

    Reply to: XMAX and XFT via CTM

    XMAX does not know where it is installed because what that really means to most people is where the location of the application hosting XMAX. For example, if you have embedded XMAX in an HTML page being hosted in IE, or in a VB application, etc, telling you where the xmcontrol.dll itself is located on your machine is typically not much use, nor would you care where iexplore.exe is. I mention this because one solution for XMetaL Author in this case is to place your XFT files into a folder and then reference them using something like [code]Application.Path + “\Forms\myfile.xft”[/code]

    There is no Application object for XMAX (like XMetaL Author has) because that is something we expect the hosting application to provide with associated properties and methods. For example, VB6 has App.Path, VB.NET and C# have Application.ExecutablePath and Application.StartupPath, etc.

    In your case (because you are scripting the CTM functionality) you will need to provide a full path to any XFT you wish to locate. XMAX does not make any assumptions in this case either.

    With an XAC file the XFT files will be extracted to the same folder as the rest of the contents of the XAC before being loaded and there are several ways to locate this folder.

    1. [code]//JScript:
    var myXFTFilePath = ActiveDocument.ResourceSet.Root + “\q-physicalsymbol”;[/code]

    In that case the folder returned is the one containing the CTM file.

    2. [code]//JScript:
    var XACTempFolder = ActiveDocument.RulesFile.substring(0,ActiveDocument.RulesFile.lastIndexOf(“\”));
    var myXFTFilePath = XACTempFolder + “\q-physicalsymbol”;[/code]

    The first method would probably be my preferred one, however, there are people out there that have relied on the second method so they may be more familiar with it. It is also possible to locate the CSS file using ActiveDocument.DisplayStylesFile (and that could be used in place of the API in the second method).

    Refer to the XMetaL Developer Programmers Guide for more information about these APIs. ResourceSet may be of particular interest as it is has a number of properties, methods and objects associated with it that allow you to query the content of XAC files in detail.

    Reply

    ghkrause

    Reply to: XMAX and XFT via CTM

    Thanks a lot, the form is now displayed when inserting the element.

    Reply

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

Lost Your Password?

Products
Downloads
Support