Topic
  • 34 replies
  • Latest Post - ‏2014-01-03T01:38:41Z by Mathias Mamsch
David Clark
David Clark
1 Post

Pinned topic Automating my MS Word Export...

‏2009-10-14T23:21:07Z |
We currently have a manual process for generating documents for our customers. We have developed a VBAScript to import three different files, merge them together and generate the documentation we need. These three files are: the contents of the Module in book form, a table view of requirements tracing, and a table of the changes since last we created the document.

These all work well. I am trying to take this to the next level. Currently we manually export these files to run with out script. I would like to have a command line ability to do this.

The problem I am running in to is the MS Word exporter has a UI and I cannot seem to bypass it.

I have looked at DocExpress, but got very lost, very quickly.

Does anyone know where to get a DXL script to export without the dialog? Or a better solution. I plan to embeded the DXL script in the VBScript and run from DOORS cli.

Thanks,

David
Updated on 2013-04-04T18:24:17Z at 2013-04-04T18:24:17Z by llandale
  • kbmurphy
    kbmurphy
    160 Posts

    Re: Automating my MS Word Export...

    ‏2009-10-15T17:06:50Z  
    You can bypass the dialog by editing the DXL. It's unencrypted. You can find it here:

    c:\<DOORS Install Path>\lib\dxl\standard\export\office\word.dxl
  • jpoindex
    jpoindex
    7 Posts

    Re: Automating my MS Word Export...

    ‏2011-02-22T15:14:21Z  
    • kbmurphy
    • ‏2009-10-15T17:06:50Z
    You can bypass the dialog by editing the DXL. It's unencrypted. You can find it here:

    c:\<DOORS Install Path>\lib\dxl\standard\export\office\word.dxl
    I am trying to do the same. I dont want the UI, just run the export in batch mode. Does anyone know how to disable the dialog from being displayed?
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2011-02-22T15:50:10Z  
    • jpoindex
    • ‏2011-02-22T15:14:21Z
    I am trying to do the same. I dont want the UI, just run the export in batch mode. Does anyone know how to disable the dialog from being displayed?
    If you do not want the gui then you will have some major modifications to do to remove everything GUI related from the word.dxl. Why don't you want to have the GUI? Instead of running in batch mode, you can do an "Interactive Batch", meaning start DOORS in interactive mode, but with a commandline option to do an export of whatever module you need to, and exit_ doors after the export.

    Regards, Mathias


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • jpoindex
    jpoindex
    7 Posts

    Re: Automating my MS Word Export...

    ‏2011-02-24T20:56:15Z  
    If you do not want the gui then you will have some major modifications to do to remove everything GUI related from the word.dxl. Why don't you want to have the GUI? Instead of running in batch mode, you can do an "Interactive Batch", meaning start DOORS in interactive mode, but with a commandline option to do an export of whatever module you need to, and exit_ doors after the export.

    Regards, Mathias


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
    Can you give me an example of running word.dxl in Interactive Batch mode. I have tried from the command using -b option and even the -D. I still get errors. I want to just try to bring up the word.dxl UI since it is a difficult to do without. Thanks
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2011-02-24T23:08:30Z  
    • jpoindex
    • ‏2011-02-24T20:56:15Z
    Can you give me an example of running word.dxl in Interactive Batch mode. I have tried from the command using -b option and even the -D. I still get errors. I want to just try to bring up the word.dxl UI since it is a difficult to do without. Thanks

    Create a file "export_batch.dxl". Put the following content in it:
     

    // override some default message box functions, so they will only print the data but 
    // not pause execution. Write to a log file here! 
     
    bool confirm (string s) { print "Confirmed: " s "\n"; return true }
    void ack (string s) {print "Acknowledge: " s "\n" }
    void acknowledge (string s) {print "Acknowledge: " s "\n"  }
    void infobox (string s) {print "Info: " s "\n" }
    void info (string s) {print "Info: " s "\n" }
     
    DB theDiag = null
     
    // Now override block and show, to only do realize
    void show  (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }
     
    if (null current Module) {
        print "You need to have a current Module set for the export."
            halt
    }
     
    // we need braces, since -D will be executed at top level and we will get name
    // clashes for variable defined in word.dxl and the other includes of it.
    {
            // now include the word.dxl -> this will pop up the dialog, but not halt execution
            // due to the overrides above
            #include <standard/export/office/word.dxl>
     
            // here we can change the dialog options. See itfui2.inc and word.dxl for all 
            // the options
            set(exportHeadingsToggle, false)   // turn off export of headings
     
            // now manually launch the export button callback
            doExport theDiag
     
            // get rid of the dialog
            if (!null theDiag) destroy theDiag
     
            // close DOORS
            exit_
    }
    

     


    Now create a batch file export.bat, and put the following in it:

     

     

     

    @echo off
    if "%~1"=="" ( 
        echo You need to start this script with a DOORS Module 
            goto :real_end
    )
     
    c:\programme\telelogic\DOORS_8.2\bin\doors.exe -f "%TEMP%" -D "current = read(\"%~1\", true); #include <export_batch.dxl>" -u Administrator
     
    :real_end
    

     


    Make sure that the export_batch.dxl and the export.bat are in the same directory. Then you can call it (from that directory, so that -D command can find the relative include!)

     

     

     

     

     

     

     

     

    export.bat "/Test/My Module33"
    

     


    Stuff like starting DOORS minimized or adding a parameter for the view to be exported, will be left as an exercise for the reader ;-) Hope this helps, Regards, Mathias

     

     

     

     

     

     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    Updated on 2013-12-18T22:20:20Z at 2013-12-18T22:20:20Z by iron-man
  • WorkingStudent
    WorkingStudent
    3 Posts

    Re: Automating my MS Word Export...

    ‏2011-03-24T15:19:04Z  
    Hey All,
    I´ve got a probleme and i don´t know how to solve it:
    Is it possible to have this script with the differnce, that you can do the export for a project and not only for a single module?

    Thanks,
    Clemens
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2011-03-25T09:46:05Z  
    Hey All,
    I´ve got a probleme and i don´t know how to solve it:
    Is it possible to have this script with the differnce, that you can do the export for a project and not only for a single module?

    Thanks,
    Clemens
    Just wrap the script in another script, that will do: for item in project do { current = read (fullName I, false); otherscript ... }. Should be doable. Regards, Mathias


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2011-10-05T23:10:48Z  
    Just wrap the script in another script, that will do: for item in project do { current = read (fullName I, false); otherscript ... }. Should be doable. Regards, Mathias


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
    Mathias,

    Your automation word script is what I have been looking for last couple days. I want to export multiple
    selected module from the GUI. Here what I have done....
    My script showing all the modules from the current folder and displaying it on a GUI which has export button. I have the option to select multiple modules from the GUI and allows me to export by pressing the export button.

    My script calls your scripts to export multiple modules. Works partially!

    There are two issues I am encountering:

    1. It exports the view to Book format. But I want to export it to Table format. How to change it in your script so that I can export all module to Table format ONLY.

    2. Word export GUI pops up before my GUI shows up. I have to close the word export GUI and then select multiple modules from my GUI. How I can stop showing word export GUI.

    I made minor changes to your script:

    a) I have moved the following lines from your script to the top of my script

    DB theDiag = null
    #include <standard/export/office/word.dxl>

    ........
    .........
    ..........

    here is the function:
    void exptMod(DB box)
    {
    int pos
    bool closeIt
    int total=0
    string attName
    int cnt=0
    int counter=0
    for pos in modListDBE do
    {
    cnt++
    }
    progressStart( copyDB, "Module Export in Progress...", "Something",cnt)
    for pos in modListDBE do
    {
    string modName = getColumnValue(modListDBE, pos, 2) "/" getColumnValue(modListDBE, pos, 0)
    string mName=getColumnValue(modListDBE, pos, 0)
    if (open(module(modName)))
    {
    closeIt = false
    }
    else
    {
    closeIt = true
    }
    progressMessage("Exporting module " mName "...........")

    destMod= read(modName, true, true)

    if(null(destMod))
    {
    storeMsg("Unable to open the module "modName)
    continue
    }
    else
    {
    destMod = read(modName, false)
    load view "CSU VCRM View"
    progressStep(counter++)
    if (closeIt)
    {
    close(destMod)
    }

    // override some default message box functions, so they will only print the data but
    // not pause execution. Write to a log file here!

    bool confirm (string s) { print "Confirmed: " s "\n"; return true }
    void ack (string s) {print "Acknowledge: " s "\n" }
    void acknowledge (string s) {print "Acknowledge: " s "\n" }
    void infobox (string s) {print "Info: " s "\n" }
    void info (string s) {print "Info: " s "\n" }

    // Now override block and show, to only do realize
    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }

    if (null current Module) {
    print "You need to have a current Module set for the export."
    halt
    }

    // we need braces, since -D will be executed at top level and we will get name
    // clashes for variable defined in word.dxl and the other includes of it.

    // now include the word.dxl -> this will pop up the dialog, but not halt execution
    // due to the overrides above

    // here we can change the dialog options. See itfui2.inc and word.dxl for all
    // the options
    set(exportHeadingsToggle, false) // turn off export of headings

    // now manually launch the export button callback
    doExport theDiag

    // get rid of the dialog
    if (!null theDiag) destroy theDiag

    // close DOORS
    // exit_

    }

    }
    progressStop
    // displayMessages
    } // copyAttsCB
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2011-10-07T04:58:52Z  
    Mathias,

    Your automation word script is what I have been looking for last couple days. I want to export multiple
    selected module from the GUI. Here what I have done....
    My script showing all the modules from the current folder and displaying it on a GUI which has export button. I have the option to select multiple modules from the GUI and allows me to export by pressing the export button.

    My script calls your scripts to export multiple modules. Works partially!

    There are two issues I am encountering:

    1. It exports the view to Book format. But I want to export it to Table format. How to change it in your script so that I can export all module to Table format ONLY.

    2. Word export GUI pops up before my GUI shows up. I have to close the word export GUI and then select multiple modules from my GUI. How I can stop showing word export GUI.

    I made minor changes to your script:

    a) I have moved the following lines from your script to the top of my script

    DB theDiag = null
    #include <standard/export/office/word.dxl>

    ........
    .........
    ..........

    here is the function:
    void exptMod(DB box)
    {
    int pos
    bool closeIt
    int total=0
    string attName
    int cnt=0
    int counter=0
    for pos in modListDBE do
    {
    cnt++
    }
    progressStart( copyDB, "Module Export in Progress...", "Something",cnt)
    for pos in modListDBE do
    {
    string modName = getColumnValue(modListDBE, pos, 2) "/" getColumnValue(modListDBE, pos, 0)
    string mName=getColumnValue(modListDBE, pos, 0)
    if (open(module(modName)))
    {
    closeIt = false
    }
    else
    {
    closeIt = true
    }
    progressMessage("Exporting module " mName "...........")

    destMod= read(modName, true, true)

    if(null(destMod))
    {
    storeMsg("Unable to open the module "modName)
    continue
    }
    else
    {
    destMod = read(modName, false)
    load view "CSU VCRM View"
    progressStep(counter++)
    if (closeIt)
    {
    close(destMod)
    }

    // override some default message box functions, so they will only print the data but
    // not pause execution. Write to a log file here!

    bool confirm (string s) { print "Confirmed: " s "\n"; return true }
    void ack (string s) {print "Acknowledge: " s "\n" }
    void acknowledge (string s) {print "Acknowledge: " s "\n" }
    void infobox (string s) {print "Info: " s "\n" }
    void info (string s) {print "Info: " s "\n" }

    // Now override block and show, to only do realize
    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }

    if (null current Module) {
    print "You need to have a current Module set for the export."
    halt
    }

    // we need braces, since -D will be executed at top level and we will get name
    // clashes for variable defined in word.dxl and the other includes of it.

    // now include the word.dxl -> this will pop up the dialog, but not halt execution
    // due to the overrides above

    // here we can change the dialog options. See itfui2.inc and word.dxl for all
    // the options
    set(exportHeadingsToggle, false) // turn off export of headings

    // now manually launch the export button callback
    doExport theDiag

    // get rid of the dialog
    if (!null theDiag) destroy theDiag

    // close DOORS
    // exit_

    }

    }
    progressStop
    // displayMessages
    } // copyAttsCB
    Try posting your code using the {co de} tag (remove space) next time. It makes it much more readable.

    Anyway, you cannot do it like that. The gist of my post was that the redirection of the show and block functions must occur before the include. You are getting an exporter box you need to click on, because the redefinition of show is done after the include.

    As you probably noticed, you cannot just move the include down to the redefinition without getting errors. This is because global variables in that include file will not be global anymore if you put the include in a function. Therefore you cannot have a function around your export code.

    So refactor your code, that the call of the exporter dialog will happen on main level again, i.e. whereever you call your exptMod function, move the code and the include statement there. Return all necessary variables for that code by references in the expmod function (or any other functions around this). If this code gets to ugly you need to strip all globals from the exporter code, put them in a separate include and include this at the top. Then you can happily move the include down below the redirection and everything shall work fine.

    Hope that helps, regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2011-10-11T22:25:19Z  
    Try posting your code using the {co de} tag (remove space) next time. It makes it much more readable.

    Anyway, you cannot do it like that. The gist of my post was that the redirection of the show and block functions must occur before the include. You are getting an exporter box you need to click on, because the redefinition of show is done after the include.

    As you probably noticed, you cannot just move the include down to the redefinition without getting errors. This is because global variables in that include file will not be global anymore if you put the include in a function. Therefore you cannot have a function around your export code.

    So refactor your code, that the call of the exporter dialog will happen on main level again, i.e. whereever you call your exptMod function, move the code and the include statement there. Return all necessary variables for that code by references in the expmod function (or any other functions around this). If this code gets to ugly you need to strip all globals from the exporter code, put them in a separate include and include this at the top. Then you can happily move the include down below the redirection and everything shall work fine.

    Hope that helps, regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
    Mathias,

    Hmm...Interesting. Now it is clear why it was showing the Word export GUI. Thank

    However, it was not clear what you mean by "wherever you call your exptMod function,move the code and the include statement there"...Where???

    exptMod function is called by the export button in my GUI function. please explain...

    Here is a pseudo code. can you give me a hint how you would have rearrange the code....

    DB theDiag = null
    #include <standard/export/office/word.dxl>

    void exptMod(DB BD)
    {

    for selectedMod in the listbox do
    {

    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }

    if (null destMod)
    {
    print "You need to have a current Module set for the export."
    halt
    }
    set(exportHeadingsToggle, false)

    doExport theDiag

    if (!null theDiag) destroy theDiag
    }

    }

    void myGUI()
    {

    .......
    .......
    .......

    okBtnDBE = ok(copyDB, "Export", exptMod)

    }
    myGUI()
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2011-10-11T22:49:21Z  
    Mathias,

    Hmm...Interesting. Now it is clear why it was showing the Word export GUI. Thank

    However, it was not clear what you mean by "wherever you call your exptMod function,move the code and the include statement there"...Where???

    exptMod function is called by the export button in my GUI function. please explain...

    Here is a pseudo code. can you give me a hint how you would have rearrange the code....

    DB theDiag = null
    #include <standard/export/office/word.dxl>

    void exptMod(DB BD)
    {

    for selectedMod in the listbox do
    {

    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }

    if (null destMod)
    {
    print "You need to have a current Module set for the export."
    halt
    }
    set(exportHeadingsToggle, false)

    doExport theDiag

    if (!null theDiag) destroy theDiag
    }

    }

    void myGUI()
    {

    .......
    .......
    .......

    okBtnDBE = ok(copyDB, "Export", exptMod)

    }
    myGUI()

    The idea was to get rid of the function, so you will have no global variable problem. The include must not be placed inside a function. Since this is not possible in your case I suggest an eval_ approach:
     

    string expCode = "
    DB theDiag = null
    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }
     
    #include <standard/export/office/word.dxl>
    set(exportHeadingsToggle, false)
    doExport theDiag
    if (!null theDiag) destroy theDiag
    "
     
    string exportCode (string sFullName) {
        string sExportCode = "
            Module mod = read(\"" sFullName "\", true)
            current = mod
            " expCode "
            close mod
        "
     
       return sExportCode
    }
     
    void exptMod(DB BD)
    {
       for selectedMod in the listbox do
       {
           eval_ exportCode selectedMod
       }
    }
    

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    Updated on 2013-12-18T22:21:21Z at 2013-12-18T22:21:21Z by iron-man
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2011-10-12T20:06:06Z  

    The idea was to get rid of the function, so you will have no global variable problem. The include must not be placed inside a function. Since this is not possible in your case I suggest an eval_ approach:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string expCode = " DB theDiag = null void show (DB x) { realize x; theDiag = x } void block (DB x) { realize x; theDiag = x } #include <standard/export/office/word.dxl> set(exportHeadingsToggle, false) doExport theDiag if (!null theDiag) destroy theDiag " string exportCode (string sFullName) { string sExportCode = " Module mod = read(\"" sFullName "\", true) current = mod " expCode " close mod " return sExportCode } void exptMod(DB BD) { for selectedMod in the listbox do { eval_ exportCode selectedMod } } </pre>

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    Mathias,

    WORKS!!!.
    The dxl is looping thru and exporting all modules. Thanks a lot!!!.

    Last question, the default word export dxl exports the module in book format. But I want the default export be in table format.

    How to force dxl to export it to table format????

    Is there any documentation in dxl help where I can get all word export functions so that I can manipulate each function such as layout, OLE and page orientation etc.
    FZ
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2011-10-13T13:09:35Z  
    Mathias,

    WORKS!!!.
    The dxl is looping thru and exporting all modules. Thanks a lot!!!.

    Last question, the default word export dxl exports the module in book format. But I want the default export be in table format.

    How to force dxl to export it to table format????

    Is there any documentation in dxl help where I can get all word export functions so that I can manipulate each function such as layout, OLE and page orientation etc.
    FZ

    You need to look at the library files of DOORS (they are not encrypted!). In itfutil.inc I find:
     

    ...
    const int layoutTypeBook                        = 0
    const int layoutTypeTable                               = 1
    const int layoutTypeMax                                 = 2
    const int layoutTypeDefault                             = layoutTypeBook
     
    const string layoutNameBook                             = "Book"
    const string layoutNameTable                            = "Table"
     
    const string layoutNamesBookOnly[]                      = {layoutNameBook}
    const string layoutNamesAll[]                           = {layoutNameBook, layoutNameTable}
    ...
    

     


    in itfui2.inc I find:

     

     

     

    ...
    void makeExporterUI(string dbTitle, int helpId, bool includeFilename, bool bookOnly, string extension, description) {
        Module m = current
        int widgetCount = 0
            
        exportBox = create(m,dbTitle, styleFixed_ | styleCentered_)
     
        ...
     
        if (bookOnly) {
            exportLayoutChoice = choice(exportBox,layoutLabel, layoutNamesBookOnly, layoutTypeDefault)
        } else {
            exportLayoutChoice = choice(exportBox,layoutLabel, layoutNamesAll, layoutTypeDefault)
        }
    ...
    



    Therefore I would think (without trying), that changing your code to:



     

     

     

    string expCode = "
    DB theDiag = null
    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }
     
    #include <standard/export/office/word.dxl>
    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook) // <<- add this line
    doExport theDiag
    if (!null theDiag) destroy theDiag
    "
    



    might do the trick ;-) I think you get the idea. Regards, Mathias



     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Updated on 2013-12-18T22:23:23Z at 2013-12-18T22:23:23Z by iron-man
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-07T19:01:52Z  
    Mathias,

    Do you know how I can set a view so that all the modules will use the user defined view, not the standard view. I tried to load the view after the module is opened, but the dxl didnot like it.

    string sExportCode = "
    Module destMod= read(\"" sFullName "\", true)
    load view ("myview")

    And I also want to apply user defined template, not the normal.dot. How to change code and make it happend.

    My impression was that the set function will allow me to change the template

    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook)
    set(autoformatToggle,false)
    set templateName ="c:\temp\mytemplate.dot" //here is the problem..
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-09T17:05:59Z  
    Mathias,

    Do you know how I can set a view so that all the modules will use the user defined view, not the standard view. I tried to load the view after the module is opened, but the dxl didnot like it.

    string sExportCode = "
    Module destMod= read(\"" sFullName "\", true)
    load view ("myview")

    And I also want to apply user defined template, not the normal.dot. How to change code and make it happend.

    My impression was that the set function will allow me to change the template

    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook)
    set(autoformatToggle,false)
    set templateName ="c:\temp\mytemplate.dot" //here is the problem..

    A new thread would have been better suited for this question. And if you post the same question twice and additionally mail it you will normally decrease the chance of getting an answer, not increase it!

    You should try something like this:
     

    set(advancedNormalTemplateToggle, false) 
    set(advancedTemplateLabel, "c:/path/to/my/template.dot")
    

     


    Also you need to be very careful about " when you put DXL code in a string:

     

     

     

    string sExportCode = "
    Module destMod= read(\"" sFullName "\", true)
    current = destMod
    load view (\"myview\")
    "
    



    should do the trick, I think you forgot the \ in front of the ". Maybe that help, regards, Mathias



     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Updated on 2013-12-18T22:25:04Z at 2013-12-18T22:25:04Z by iron-man
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-09T20:06:44Z  

    A new thread would have been better suited for this question. And if you post the same question twice and additionally mail it you will normally decrease the chance of getting an answer, not increase it!

    You should try something like this:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">set(advancedNormalTemplateToggle, false) set(advancedTemplateLabel, "c:/path/to/my/template.dot") </pre>

     


    Also you need to be very careful about " when you put DXL code in a string:

     

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string sExportCode = " Module destMod= read(\"" sFullName "\", true) current = destMod load view (\"myview\") " </pre>



    should do the trick, I think you forgot the \ in front of the ". Maybe that help, regards, Mathias



     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Mathias,

    Thanks for your suggestion what is the best way to post new threads and the feedback for the code.
    I encoutered a problem,

    .....
    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook)
    set(autoformatToggle,false)
    set(advancedNormalTemplateToggle, false)
    set(advancedTemplateLabel,"c:/temp/template.dot")

    if I use the "c:/..." like the above code. I get an error message:

    -E- DXL: <Line:49> incorrectly concatenated tokens
    -E- DXL: <Line:49> undeclared variable (c)
    -E- DXL: <Line:49> syntax error
    -I- DXL: All done. Errors reported: 3. Warnings reported: 0.
    set(advancedNormalTemplateToggle, false)
    set(advancedTemplateLabel,c:/temp/template.dot)

    If I don't use the "", Only the path c:/temp/template.dot, the GUI pops up and allows me to select modules then crushes. I get the following error message:

    -E- DXL: <Line:16> syntax error
    -E- DXL: <Line:16> undeclared variable (c)
    -E- DXL: <Line:16> syntax error
    -E- DXL: <Line:16> undeclared variable (c)

    Any suggestion!

    thanks

    fz
  • Mathias Mamsch
    Mathias Mamsch
    2003 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-10T13:08:09Z  
    Mathias,

    Thanks for your suggestion what is the best way to post new threads and the feedback for the code.
    I encoutered a problem,

    .....
    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook)
    set(autoformatToggle,false)
    set(advancedNormalTemplateToggle, false)
    set(advancedTemplateLabel,"c:/temp/template.dot")

    if I use the "c:/..." like the above code. I get an error message:

    -E- DXL: <Line:49> incorrectly concatenated tokens
    -E- DXL: <Line:49> undeclared variable (c)
    -E- DXL: <Line:49> syntax error
    -I- DXL: All done. Errors reported: 3. Warnings reported: 0.
    set(advancedNormalTemplateToggle, false)
    set(advancedTemplateLabel,c:/temp/template.dot)

    If I don't use the "", Only the path c:/temp/template.dot, the GUI pops up and allows me to select modules then crushes. I get the following error message:

    -E- DXL: <Line:16> syntax error
    -E- DXL: <Line:16> undeclared variable (c)
    -E- DXL: <Line:16> syntax error
    -E- DXL: <Line:16> undeclared variable (c)

    Any suggestion!

    thanks

    fz

    Read my comment again. You need to be careful with the " in the code. If you embed the code into a string, you need to escape the " characters. The reason that you got this message is that you tried to embed the code in a string and again forgot to escape the template string. Therefore he tried to do

    "..." c :/ ...
    

     


    Stopping at c, telling you it is an undeclared variable ... Regards, Mathias

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Updated on 2013-12-18T22:25:41Z at 2013-12-18T22:25:41Z by iron-man
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-12T15:45:41Z  

    Read my comment again. You need to be careful with the " in the code. If you embed the code into a string, you need to escape the " characters. The reason that you got this message is that you tried to embed the code in a string and again forgot to escape the template string. Therefore he tried to do

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">"..." c :/ ... </pre>

     


    Stopping at c, telling you it is an undeclared variable ... Regards, Mathias

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Mathias,

    Now I got really confused!!!
    When you say escape the " character. what you mean by that??
    If I don't use the " in the c:/temp/template.dot, the dxl allows me to launch the form. the next step is to select the modules from GUI and run. As soon as I do that again I get the same error message.

    -E- DXL: <Line:16> incorrect arguments for function (set)
    -E- DXL: <Line:18> syntax error
    -E- DXL: <Line:18> undeclared variable (c)

    Here is the code. can you show me what you are trying to say...
    string expCode = "
    DB theDiag = null
    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }
    #include <standard/export/office/word.dxl>
    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook)
    set(autoformatToggle,false)
    set(useNormalTemplate,false)
    set(advancedNormalTemplateToggle, false)
    set(advancedTemplateLabel,c:/temp/template.dot)

    doExport theDiag
    if (!null theDiag) destroy theDiag
    "
    ...........................
    .........................
    Thanks,

    Appreciate it!!

    FZ
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-12T17:21:36Z  
    Mathias,

    Now I got really confused!!!
    When you say escape the " character. what you mean by that??
    If I don't use the " in the c:/temp/template.dot, the dxl allows me to launch the form. the next step is to select the modules from GUI and run. As soon as I do that again I get the same error message.

    -E- DXL: <Line:16> incorrect arguments for function (set)
    -E- DXL: <Line:18> syntax error
    -E- DXL: <Line:18> undeclared variable (c)

    Here is the code. can you show me what you are trying to say...
    string expCode = "
    DB theDiag = null
    void show (DB x) { realize x; theDiag = x }
    void block (DB x) { realize x; theDiag = x }
    #include <standard/export/office/word.dxl>
    set(exportHeadingsToggle, false)
    set(exportLayoutChoice, layoutTypeBook)
    set(autoformatToggle,false)
    set(useNormalTemplate,false)
    set(advancedNormalTemplateToggle, false)
    set(advancedTemplateLabel,c:/temp/template.dot)

    doExport theDiag
    if (!null theDiag) destroy theDiag
    "
    ...........................
    .........................
    Thanks,

    Appreciate it!!

    FZ

    Hello FZ,

    about "escaping":
    let's go back one step.

    you need to define a string that contains the " character, because the set command needs a string as its second parameter.

    In DXL, as in many other languages, the content of the string is enclosed in " characters.
    So, in a usual code you would write the line

    string s = "<This is a string>"
    

     


    If you execute this code, you have a variable which contains the text

     

     

    <This is a string>
    


    Now, if you want to have a variable which contains the text

     

     

    <This is a string having the character " in the middle>
    


    and you would write it in this way:

     

     

    string s ="<This is a string having the character " in the middle>"
    


    then the parser would read the line and think that the content of the string ends after the second " character.
    So, DXL would think that string s shall contain

     

     

    <This is a string having the character
    


    and afterwards it would find some gibberish command

     

     

    in the middle>
    


    and would complain, because such a command makes no sense.

    So, what do you do to tell DXL that you actually want a " character in the middle of the string? You tell it that the " character shall not be the end of the string, it shall be read just as it is.
    This is done by preceding the " character with a so-called "escape"-character. This escape character says: ignore the next character you find in the code.
    In DXL, the escape character is the backslash \
    To conclude the example, you would have to write the code as such

     

     

    string s = "<This is a string having the character \" in the middle>"
    


    (I hope that your browser or email client does not mess up this line. There is a backslash, then a quotation mark.

    And finally, to come back to your original question, you would have to write the following line:

     

     

    set(advancedTemplateLabel,"\c:/temp/template.dot"\)
    


    because your string begins in line 1 (string expCode= ") and ends in the line containing only a " character. All " in the middle must be preceded (escaped) by a \
    Hope this helps.
    Regards,
    Mike

    PS: http://en.wikipedia.org/wiki/Escape_character

     

    Updated on 2013-12-18T22:30:03Z at 2013-12-18T22:30:03Z by iron-man
  • llandale
    llandale
    3005 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-13T17:15:01Z  

    Hello FZ,

    about "escaping":
    let's go back one step.

    you need to define a string that contains the " character, because the set command needs a string as its second parameter.

    In DXL, as in many other languages, the content of the string is enclosed in " characters.
    So, in a usual code you would write the line

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string s = "<This is a string>" </pre>

     


    If you execute this code, you have a variable which contains the text

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr"><This is a string> </pre>


    Now, if you want to have a variable which contains the text

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr"><This is a string having the character " in the middle> </pre>


    and you would write it in this way:

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string s ="<This is a string having the character " in the middle>" </pre>


    then the parser would read the line and think that the content of the string ends after the second " character.
    So, DXL would think that string s shall contain

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr"><This is a string having the character </pre>


    and afterwards it would find some gibberish command

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">in the middle> </pre>


    and would complain, because such a command makes no sense.

    So, what do you do to tell DXL that you actually want a " character in the middle of the string? You tell it that the " character shall not be the end of the string, it shall be read just as it is.
    This is done by preceding the " character with a so-called "escape"-character. This escape character says: ignore the next character you find in the code.
    In DXL, the escape character is the backslash \
    To conclude the example, you would have to write the code as such

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string s = "<This is a string having the character \" in the middle>" </pre>


    (I hope that your browser or email client does not mess up this line. There is a backslash, then a quotation mark.

    And finally, to come back to your original question, you would have to write the following line:

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">set(advancedTemplateLabel,"\c:/temp/template.dot"\) </pre>


    because your string begins in line 1 (string expCode= ") and ends in the line containing only a " character. All " in the middle must be preceded (escaped) by a \
    Hope this helps.
    Regards,
    Mike

    PS: http://en.wikipedia.org/wiki/Escape_character

     

    I may not be following this thread correctly, but perhaps you have the slashes in the wrong spot:
    • from .. set(advancedTemplateLabel,"\c:/temp/template.dot"\)
    • to ...... set(advancedTemplateLabel,\"c:/temp/template.dot\")
    If the file path had front slashes instead of back slashes, you would need to escape them as well:
    Run this code:
    • print "set(advancedTemplateLabel,\"c:\\temp\\template.dot\")"
    and you get this:
    • set(advancedTemplateLabel,"c:\temp\template.dot")

    Confused? There are 3 people in the entire world who visualize this effortlessly, I'm not one of them. So I type what I want to see, then add an escape front-slash in front of the double quotes and front-slashes. When I have such strings that are not working, I try to just print the parts.

    -Louie
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-13T17:27:39Z  
    • llandale
    • ‏2012-03-13T17:15:01Z
    I may not be following this thread correctly, but perhaps you have the slashes in the wrong spot:
    • from .. set(advancedTemplateLabel,"\c:/temp/template.dot"\)
    • to ...... set(advancedTemplateLabel,\"c:/temp/template.dot\")
    If the file path had front slashes instead of back slashes, you would need to escape them as well:
    Run this code:
    • print "set(advancedTemplateLabel,\"c:\\temp\\template.dot\")"
    and you get this:
    • set(advancedTemplateLabel,"c:\temp\template.dot")

    Confused? There are 3 people in the entire world who visualize this effortlessly, I'm not one of them. So I type what I want to see, then add an escape front-slash in front of the double quotes and front-slashes. When I have such strings that are not working, I try to just print the parts.

    -Louie
    > from .. set(advancedTemplateLabel,"\c:/temp/template.dot"\) to .. \" ..

    Oops, I stand corrected. Thanks for proof reading my mail:-)

    Mike
  • faisal.zahidi@boeing.com
    53 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-13T18:43:09Z  
    > from .. set(advancedTemplateLabel,"\c:/temp/template.dot"\) to .. \" ..

    Oops, I stand corrected. Thanks for proof reading my mail:-)

    Mike
    Louie/Mike,

    If I use the following code:

    set(advancedTemplateLabel,\"c:/temp/template.dot\")

    I get an error message:

    -E- DXL: <Line:16> incorrect arguments for function (set)

    Am I doing something wrong????

    Thanks,

    Faisal Zahidi
  • llandale
    llandale
    3005 Posts

    Re: Automating my MS Word Export...

    ‏2012-03-13T20:21:21Z  
    Louie/Mike,

    If I use the following code:

    set(advancedTemplateLabel,\"c:/temp/template.dot\")

    I get an error message:

    -E- DXL: <Line:16> incorrect arguments for function (set)

    Am I doing something wrong????

    Thanks,

    Faisal Zahidi
    You escape when you are sending the string elsewhere, in this case I think its the "eval_" function. If you are just coding and running you don't need them.
    • set(advancedTemplateLabel,"c:/temp/template.dot") // this works
    • eval_("set(advancedTemplateLabel,\"c:/temp/template.dot\")") // this sends it elsewhere

    ..err.. I should say you need to escape when the quotes and the slashes are inside some other string.
    • print "set(advancedTemplateLabel,\"c:/temp/template.dot\")\n"
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: Automating my MS Word Export...

    ‏2012-08-08T14:56:58Z  

    A new thread would have been better suited for this question. And if you post the same question twice and additionally mail it you will normally decrease the chance of getting an answer, not increase it!

    You should try something like this:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">set(advancedNormalTemplateToggle, false) set(advancedTemplateLabel, "c:/path/to/my/template.dot") </pre>

     


    Also you need to be very careful about " when you put DXL code in a string:

     

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string sExportCode = " Module destMod= read(\"" sFullName "\", true) current = destMod load view (\"myview\") " </pre>



    should do the trick, I think you forgot the \ in front of the ". Maybe that help, regards, Mathias



     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Hello,

    Is there a way of saving the export once it is complete?

    Thank you,
    -Jim
     

    Skip selectedItems = getSelectedItems ()
    Item I = null
    for I in selectedItems do
    {
        if(isDeleted(I) || null I) {continue}
            if (type (I) == "Formal")
            {
                    Module m = read(fullName(I),true)
                    load view "Standard view"
                    delete column 0
                    {
                            // override some default message box functions, so they will only print the data but 
                            // not pause execution. Write to a log file here! 
                             
                            bool confirm (string s) { print "Confirmed: " s "\n"; return true }
                            void ack (string s) {print "Acknowledge: " s "\n" }
                            void acknowledge (string s) {print "Acknowledge: " s "\n"  }
                            void infobox (string s) {print "Info: " s "\n" }
                            void info (string s) {print "Info: " s "\n" }
                             
                            DB theDiag = null
                             
                            // Now override block and show, to only do realize
                            void show  (DB x) { realize x; theDiag = x }
                            void block (DB x) { realize x; theDiag = x }
                             
                            if (null current Module) {
                                    print "You need to have a current Module set for the export."
                                    halt
                            }
                             
                            // we need braces, since -D will be executed at top level and we will get name
                            // clashes for variable defined in word.dxl and the other includes of it.
                            {
                                    // now include the word.dxl -> this will pop up the dialog, but not halt execution
                                    // due to the overrides above
                                    #include <standard/export/office/word.dxl>
                             
                                    // here we can change the dialog options. See itfui2.inc and word.dxl for all 
                                    // the options
                                    set(exportHeadingsToggle, false)   // turn off export of headings
                                    set(exportWarnUnregOLE,false)   //turn off ole warning
                             
                                    // now manually launch the export button callback
                                    doExport theDiag
                             
                                    // get rid of the dialog
                                    if (!null theDiag) destroy theDiag
                             
                                    // close DOORS
                                    //exit_
                            }
                    }
                    close(m)
            }
    }
     
    delete selectedItems
    
    Updated on 2013-12-18T22:31:14Z at 2013-12-18T22:31:14Z by iron-man