I'm trying to export the contents of any given module via a DXL script into a *.tex file instead of trying to use the native Word export routine or into Word via Excel. (Both of which are very clunky and unwieldy.)
When I try to evaluate a single object, the DXL script that I have written is able to properly pull the attributes for the previous object via previous(Object o)
.
However, when I do a for o in m do
loop for the contents of an entire module, DOORS does not correctly update the previous object (and associated attributes) in each iteration, instead, it is retaining the initial value.
This is my current code:
Module m = current
Object o = current
Object po = previous(Object o)
Object no = next(Object o)
int column = 0
for o in m do {
if (probeAttr_(o, "Category") == "Table") {
refresh(m)
if (probeAttr_(o, "Category") != probeAttr_(po, "Category")) {
if (probeAttr_(o, "Table Column 4") != "") {
column = 4
print "\\begin{longtable}""\n"
print " {| p{.05\\textwidth} | p{.275\\textwidth} | p{.275\\textwidth} | p{.275\\textwidth} |}""\n"
print "\\caption{" po."DXL Text" "}""\n"
print "\\hline""\n"
print o."Table Column 1" " & " o."Table Column 2" " & "o."Table Column 3" " & " o."Table Column 4""\n"
}
else if ((probeAttr_(o, "Table Column 4") == null) and (probeAttr_(o, "Table Column 3") != "")) {
column = 3
print "\\begin{longtable}""\n"
print " {| p{.05\\textwidth} | p{.55\\textwidth} | p{.55\\textwidth} |}""\n"
print "\\caption{" po."DXL Text" "}""\n"
print "\\hline""\n"
print o."Table Column 1" " & " o."Table Column 2" " & "o."Table Column 3""\n"
}
else {
print column " " probeAttr_(o, "Absolute Number")" "probeAttr_(po, "Absolute Number")" ""\n"
print "\\begin{longtable}""\n"
print " {| p{.55\\textwidth} | p{.55\\textwidth} |}""\n"
print "\\caption{" po."DXL Text" "}""\n"
print "\\hline""\n"
print o."Table Column 1" " & " o."Table Column 2""\n"
}
}
else if (probeAttr_(o, "Category") != probeAttr_(no, "Category")) {
if (column == 4) {
print o."Table Column 1" " & " o."Table Column 2" " & "o."Table Column 3" " & " o."Table Column 4""\n"
print "\\end{longtable}""\n"
}
else if (column == 3) {
print o."Table Column 1" " & " o."Table Column 2" " & "o."Table Column 3""\n"
print "\\end{longtable}""\n"
}
else {
print o."Table Column 1" " & " o."Table Column 2""\n"
print "\\end{longtable}""\n"
}
column = 0
}
else {
if (column == 4) {
print o."Table Column 1" " & " o."Table Column 2" " & "o."Table Column 3" " & " o."Table Column 4""\n"
}
else if (column == 3) {
print o."Table Column 1" " & " o."Table Column 2" " & "o."Table Column 3""\n"
}
else {
print o."Table Column 1" " & " o."Table Column 2""\n"
}
}
}
}
If I have five objects with Absolute Numbers 1, 2, 3, 4, and 5, and 1 and 5 both have different categories than 2, 3, and 4, what I am expecting is that I would see that the code would spit out something like:
...
\begin{longtable}
{| p{.05\textwidth} | p{.275\textwidth} | p{.275\textwidth} | p{.275\textwidth} |}
\caption{1 Object Text}
\hline
2o.Table Column 1 & 2o.Table Column 2 & 2o.Table Column 3 & 2o.Table Column 4
3o.Table Column 1 & 3o.Table Column 2 & 3o.Table Column 3 & 3o.Table Column 4
4o.Table Column 1 & 4o.Table Column 2 & 4o.Table Column 3 & 4o.Table Column 4
\end{longtable}
...
However, what I get is:
...
\begin{longtable}
{| p{.05\textwidth} | p{.275\textwidth} | p{.275\textwidth} | p{.275\textwidth} |}
\caption{1 Object Text}
\hline
2o.Table Column 1 & 2o.Table Column 2 & 2o.Table Column 3 & 2o.Table Column 4
\begin{longtable}
{| p{.05\textwidth} | p{.275\textwidth} | p{.275\textwidth} | p{.275\textwidth} |}
\caption{1 Object Text}
\hline
3o.Table Column 1 & 3o.Table Column 2 & 3o.Table Column 3 & 3o.Table Column 4
\begin{longtable}
{| p{.05\textwidth} | p{.275\textwidth} | p{.275\textwidth} | p{.275\textwidth} |}
\caption{1 Object Text}
\hline
4o.Table Column 1 & 4o.Table Column 2 & 4o.Table Column 3 & 4o.Table Column 4
...
Is there a different way of doing this loop that doesn't resort to using for
?
How I would do this in Excel is just increment through and evaluate each row but I'm not as familiar with DXL or C++ as I am with VBA.
you have to reassign previous (and next) every iteration of the for loop.
for obj in mod do {
po = previous(obj)
no = next(obj)
you don't need the refresh.