Mistakes with dxl script in Batch Mode

Hi all,

string RifFilename = "C:\\Documents and Settings\\...\\...\\rifExport.xml"
 
current = folder "/folder_xy"
Folder parent = current
 
string targetname = null
 
string targetDesc = "Description"
string RifDefName = "DefName"
string RifDescription = null
 
string s = ""
DB myDB = null
 
s=importRifFile(RifFilename, parent, targetname, targetDesc, RifDefName, RifDescription, myDB)
if(s!="")
{
print "Error occured: " s "\n"
}


Under Doors runs script without mistake, however, in BatchMode I get the following mistakes:

1.<parent> already declared in this scope
2.incorrect arguments for function importRifFile

Thank you for help!


VBdo - Mon Feb 21 05:09:06 EST 2011

Re: Mistakes with dxl script in Batch Mode
SystemAdmin - Mon Feb 21 05:30:28 EST 2011

I'm not an expert on batch mode but I need the experience! So here goes!

If I was to put my finger on the problem, I think it's either the myDB Dialogue Box call or the statement "print "Error occured: " s "\n" or both.

Batch mode cannot raise the DXL Interaction window to display the print statement during batch mode. Same goes for any dialogue boxes.

Do I get any marks or did I fail miserably?


Paul Miller
Melbourne, Australia

Re: Mistakes with dxl script in Batch Mode
VBdo - Mon Feb 21 05:38:53 EST 2011

SystemAdmin - Mon Feb 21 05:30:28 EST 2011
I'm not an expert on batch mode but I need the experience! So here goes!

If I was to put my finger on the problem, I think it's either the myDB Dialogue Box call or the statement "print "Error occured: " s "\n" or both.

Batch mode cannot raise the DXL Interaction window to display the print statement during batch mode. Same goes for any dialogue boxes.

Do I get any marks or did I fail miserably?


Paul Miller
Melbourne, Australia

I have another Script, that also has print statement, and works without problems!

Re: Mistakes with dxl script in Batch Mode
SystemAdmin - Mon Feb 21 06:24:22 EST 2011

VBdo - Mon Feb 21 05:38:53 EST 2011
I have another Script, that also has print statement, and works without problems!

Looks like I failed miserably :-)

Over to Louie, Mathias or others to solve this one.
Paul Miller
Melbourne, Australia

Re: Mistakes with dxl script in Batch Mode
Mathias Mamsch - Mon Feb 21 06:25:32 EST 2011

There are two possible reasons for this:

1. In batch mode your script will be executed at a different context as in "Interactive Mode". In Interactive mode DOORS will create its own DXL context and add { attrDxlName = ...; obj__ = ...; your script goes here } to your script, I think that won't happen in batch mode. Therefore in batch mode your script will conflict, since "parent" is already defined on top level (and is a function).

2. In batch mode other include files than in interactive modes are loaded at startup. It may be that one of the includes already defines a 'parent' variable or function.

So you should:
a) use a different name for your variable
(or b) wrap your program in curly braces to avoid the name clash.

Regards,Mathias


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

Re: Mistakes with dxl script in Batch Mode
VBdo - Mon Feb 21 07:37:42 EST 2011

Mathias Mamsch - Mon Feb 21 06:25:32 EST 2011
There are two possible reasons for this:

1. In batch mode your script will be executed at a different context as in "Interactive Mode". In Interactive mode DOORS will create its own DXL context and add { attrDxlName = ...; obj__ = ...; your script goes here } to your script, I think that won't happen in batch mode. Therefore in batch mode your script will conflict, since "parent" is already defined on top level (and is a function).

2. In batch mode other include files than in interactive modes are loaded at startup. It may be that one of the includes already defines a 'parent' variable or function.

So you should:
a) use a different name for your variable
(or b) wrap your program in curly braces to avoid the name clash.

Regards,Mathias


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

Thank you Mathias,
a) was right for me!

Re: Mistakes with dxl script in Batch Mode
llandale - Mon Feb 21 11:55:26 EST 2011

VBdo - Mon Feb 21 07:37:42 EST 2011
Thank you Mathias,
a) was right for me!

b) is also right. Well "right" in the sense of getting rid of this problem; my batch scripts have been working fine for a long time without it, but that's primarily because I write modular code and rarely have anything much defined in the "main" context anyway.

  • Louie

Re: Mistakes with dxl script in Batch Mode
lsand - Thu Apr 14 16:28:31 EDT 2011

llandale - Mon Feb 21 11:55:26 EST 2011
b) is also right. Well "right" in the sense of getting rid of this problem; my batch scripts have been working fine for a long time without it, but that's primarily because I write modular code and rarely have anything much defined in the "main" context anyway.

  • Louie

I don't understand option b)...can you explain a little more? I am having the same problems when I try to run in batch mode...

Re: Mistakes with dxl script in Batch Mode
lsand - Thu Apr 14 16:30:00 EDT 2011

lsand - Thu Apr 14 16:28:31 EDT 2011
I don't understand option b)...can you explain a little more? I am having the same problems when I try to run in batch mode...

I changed my variable name and now I get a bunch of errors regarding an invalid argument type.

Re: Mistakes with dxl script in Batch Mode
lsand - Thu Apr 14 16:32:02 EDT 2011

lsand - Thu Apr 14 16:30:00 EDT 2011
I changed my variable name and now I get a bunch of errors regarding an invalid argument type.

I take that back. After I changed the variable name, I ran it without saving thus all the errors. works great, but would still like to hear more about option b.

Re: Mistakes with dxl script in Batch Mode
llandale - Thu Apr 14 18:19:00 EDT 2011

lsand - Thu Apr 14 16:32:02 EDT 2011
I take that back. After I changed the variable name, I ran it without saving thus all the errors. works great, but would still like to hear more about option b.

Option B says that if this works on-demand:

infoBox("Whatever")


then this will work in Batch Mode:

 

{
infoBox("Whatever")
}


Don't know why.

 

 

 

  • Louie

 

 

Re: Mistakes with dxl script in Batch Mode
vasgyuszi - Tue May 17 10:26:06 EDT 2011

SystemAdmin - Mon Feb 21 05:30:28 EST 2011
I'm not an expert on batch mode but I need the experience! So here goes!

If I was to put my finger on the problem, I think it's either the myDB Dialogue Box call or the statement "print "Error occured: " s "\n" or both.

Batch mode cannot raise the DXL Interaction window to display the print statement during batch mode. Same goes for any dialogue boxes.

Do I get any marks or did I fail miserably?


Paul Miller
Melbourne, Australia

Dear Experts,

I've got a very similar problem, but the receiver error messages point to DOORS internal sources and not to mine.

The situation:
1) script runs in interactive mode perfectly
2) in batchmode (-b "Windows path to the dxl file") receive errors, but my script itself delivers perfect results
3) I've turned off the visibility of the loaded basilne within my script (which makes the result useless) and than runs through even in batchmode withouot errors.

Weird...

The error messages are:

-E- DXL: <config/colmenu.inc:24> incorrect arguments for function (createItem)
Included from:
    <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:24> undeclared variable (alwaysOn)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:28> incorrect arguments for function (createItem)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:28> undeclared variable (columnSelected)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:34> incorrect arguments for function (createItem)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:34> undeclared variable (alwaysOn)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:37> incorrect arguments for function (createItem)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:37> undeclared variable (columnSelected)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/formal:29> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formal:29> undeclared variable (lockSection)
Included from:
        <Line:1> 
  too many messages -- suspending error reporting-I- DXL: all done with 516 errors and 0 warnings
-E- DOORS: DXL contains 516 errors
-E- DXL: <config/formalheading:23> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:23> undeclared variable (alwaysOn)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:26> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:26> undeclared variable (columnSelected)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:45> incorrect arguments for function (createMenu)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:45> undeclared variable (canSortMap)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:47> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:47> undeclared variable (canSortAscending)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:47> undeclared variable (canSortAscendingMap)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:50> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
  too many messages -- suspending error reporting-I- DXL: all done with 13 errors and 0 warnings
-E- DOORS: DXL contains 13 errors

 


and my script as follows:

 

 

string out_filename 
 
const string sourceModuleName = "/M3AR/Modules/HRCX/LLR_SW_HRCX"
 
Baseline b = baseline(2,0,"BASELINESET_CRCX_07.06_08.10")
 
const string colId = "Req.ID"
const string colCode = "Source Code"   
 
/*
* function for exporting the given module to csv file
* the columns to export are defined below
*/
string exportToCsvPld(string mName, string viewName)
{
    Module m = current
    string attrbName
    Object o
    string inhalt
    string separator = ","
    string hochkomma = "\""
 
    m = read(mName, false)
    if (null m) { errorBox "Failed to open module " mName "."; return }
    else current = m
 
    load(m,b,true)
    load view viewName
 
    out_filename = out_filename ".csv"
    if (canOpenFile(out_filename, false)) deleteFile(out_filename)
    Stream app = append out_filename
    
    app << hochkomma
    app << colId
    app << hochkomma
    app << separator 
    app << colCode 
    app << "\n"
    app << hochkomma
    app << "__View__"
    app << hochkomma
    app << separator 
    app << hochkomma
    app << "View: " viewName " / Baseline: " (major b)"."(minor b)" "(suffix b)
    app << hochkomma
    app << "\n"
    
    for o in current Module do {
        inhalt = o.colId
        app << hochkomma
        app << inhalt 
        app << hochkomma
        app << separator 
        app << hochkomma
        inhalt = o.colCode  
        app << inhalt 
        app << hochkomma
        app << "\n"
    }
    
    close app
    close m
    close current Module
    return("")
    
}//string exportToCsvPld(string mName, string viewName)
 
 
/* first count all Items */
Item m
int numberOfItems =0
Project p
for p in database do for m in p do if (type(m) == "Formal") numberOfItems++
 
/* read all modules to string array, for further use in list box */
string modules[numberOfItems]
int i =0
for p in database do {
    for m in p do {
        if (type(m) == "Formal") {
            modules[i]=fullName m
            i++
        }
    }
}
 
out_filename = (getenv "TEMP") "\\traceability\\requirements"
exportToCsvPld(sourceModuleName, "SW CPLD DO-Release view")
if (batchMode) exit_



Thanks in advance,
vasgyuszi



 

Re: Mistakes with dxl script in Batch Mode
llandale - Tue May 17 11:35:15 EDT 2011

vasgyuszi - Tue May 17 10:26:06 EDT 2011

Dear Experts,

I've got a very similar problem, but the receiver error messages point to DOORS internal sources and not to mine.

The situation:
1) script runs in interactive mode perfectly
2) in batchmode (-b "Windows path to the dxl file") receive errors, but my script itself delivers perfect results
3) I've turned off the visibility of the loaded basilne within my script (which makes the result useless) and than runs through even in batchmode withouot errors.

Weird...

The error messages are:

-E- DXL: <config/colmenu.inc:24> incorrect arguments for function (createItem)
Included from:
    <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:24> undeclared variable (alwaysOn)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:28> incorrect arguments for function (createItem)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:28> undeclared variable (columnSelected)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:34> incorrect arguments for function (createItem)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:34> undeclared variable (alwaysOn)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:37> incorrect arguments for function (createItem)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/colmenu.inc:37> undeclared variable (columnSelected)
Included from:
        <config/formal:20> 
        <Line:1> 
-E- DXL: <config/formal:29> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formal:29> undeclared variable (lockSection)
Included from:
        <Line:1> 
  too many messages -- suspending error reporting-I- DXL: all done with 516 errors and 0 warnings
-E- DOORS: DXL contains 516 errors
-E- DXL: <config/formalheading:23> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:23> undeclared variable (alwaysOn)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:26> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:26> undeclared variable (columnSelected)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:45> incorrect arguments for function (createMenu)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:45> undeclared variable (canSortMap)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:47> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:47> undeclared variable (canSortAscending)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:47> undeclared variable (canSortAscendingMap)
Included from:
        <Line:1> 
-E- DXL: <config/formalheading:50> incorrect arguments for function (createItem)
Included from:
        <Line:1> 
  too many messages -- suspending error reporting-I- DXL: all done with 13 errors and 0 warnings
-E- DOORS: DXL contains 13 errors

 


and my script as follows:

 

 

string out_filename 
 
const string sourceModuleName = "/M3AR/Modules/HRCX/LLR_SW_HRCX"
 
Baseline b = baseline(2,0,"BASELINESET_CRCX_07.06_08.10")
 
const string colId = "Req.ID"
const string colCode = "Source Code"   
 
/*
* function for exporting the given module to csv file
* the columns to export are defined below
*/
string exportToCsvPld(string mName, string viewName)
{
    Module m = current
    string attrbName
    Object o
    string inhalt
    string separator = ","
    string hochkomma = "\""
 
    m = read(mName, false)
    if (null m) { errorBox "Failed to open module " mName "."; return }
    else current = m
 
    load(m,b,true)
    load view viewName
 
    out_filename = out_filename ".csv"
    if (canOpenFile(out_filename, false)) deleteFile(out_filename)
    Stream app = append out_filename
    
    app << hochkomma
    app << colId
    app << hochkomma
    app << separator 
    app << colCode 
    app << "\n"
    app << hochkomma
    app << "__View__"
    app << hochkomma
    app << separator 
    app << hochkomma
    app << "View: " viewName " / Baseline: " (major b)"."(minor b)" "(suffix b)
    app << hochkomma
    app << "\n"
    
    for o in current Module do {
        inhalt = o.colId
        app << hochkomma
        app << inhalt 
        app << hochkomma
        app << separator 
        app << hochkomma
        inhalt = o.colCode  
        app << inhalt 
        app << hochkomma
        app << "\n"
    }
    
    close app
    close m
    close current Module
    return("")
    
}//string exportToCsvPld(string mName, string viewName)
 
 
/* first count all Items */
Item m
int numberOfItems =0
Project p
for p in database do for m in p do if (type(m) == "Formal") numberOfItems++
 
/* read all modules to string array, for further use in list box */
string modules[numberOfItems]
int i =0
for p in database do {
    for m in p do {
        if (type(m) == "Formal") {
            modules[i]=fullName m
            i++
        }
    }
}
 
out_filename = (getenv "TEMP") "\\traceability\\requirements"
exportToCsvPld(sourceModuleName, "SW CPLD DO-Release view")
if (batchMode) exit_



Thanks in advance,
vasgyuszi



 

The purpose of Batch Mode is to run some code and then exit without user interaction. Batch Mode scripts are ideal for scheduling late at night.

Batch Mode lacks functions dealing with GUI and that's why you get these DXL errors. It does not make sense to be building a GUI "menu" in an environment that has no GUI what so ever.

If you are indeed trying to build GUI in batch mode then you have a conceptualization problem as to what you are trying to accomplish and how you figure to do it.

You need to find another way to tell your batch program what its supposed to do, and then let it do it. Perhaps

Folder fldStart = folder("\MyProj\MyFold")
current = fldStart
DoWhatIWant(fldStart)

If you really want to schedule some task to run at a certain time but also to prompt the user as to what to do, then don't use "batch mode" you can use the '-dxl' switch to
iniatiate your dialog code.

  • Louie