我希望有人可以帮助我解决这个问题:(我之前已经搜索过其他问题是否适合...)
我正在尝试使用递归 DXL 函数列出特定目录中的所有 DOORS 模块,并将模块名称(完整路径/名称)写入 Excel 表
这是我到现在为止得到的......问题似乎是“z”再次重置为1
在 Excel VBA 中,我像这样调用 DXL 脚本(有效):
objDoorsApp.runStr ("#include <" & sInterface & ">;;createFolderNameForRecursion ()")
它调用一个函数来最初调用递归函数:(也可以)
void createFolderNameForRecursion()
{
int z = 1
WriteAllModulesRecursively2ExistExcel(folder("/00_Platform/30Software/30_Basis_SW/IoStck"), z);
}
这是递归函数:
void WriteAllModulesRecursively2ExistExcel(Folder f, int z) 
{
Item i
Module m
string ausgabe,temp
OleAutoObj  objExcel = oleGetAutoObject("Excel.Application")
OleAutoObj  objBook
OleAutoObj  objSheet = null
OleAutoArgs oleArgs = create
Object  oCur
Module  mCur
bool    excelVisible 
string  sTemp = ""
string  sResult = ""
//int   iRow = 1
string sBookName = "PP_Tst_IT_Report_Template.xls"
string sSheetName = "Delivery"
string result = ""
/* Make Excel visible to the user */
oleGet(objExcel, "Visible", excelVisible) 
if (!excelVisible) olePut(objExcel,"visible",true)
/* Get workbook */
sResult = oleGet(objExcel,"Workbooks", sBookName)
/* Get a handle on Sheet 1 in active workbook */
clear oleArgs
put(oleArgs, sSheetName) 
sResult = oleGet(objExcel, "Sheets", oleArgs, objSheet)
for i in f do 
{
    if (type(i)=="Folder" || type(i) =="Project") {  WriteAllModulesRecursively2ExistExcel(folder(i), z) }
    if (type(i)=="Formal")
    {
        sTemp = fullName i
        if (sTemp!=null)
        {       
            result = z " --> " fullName i "\n"
            objCell = ExcelGetCell(objSheet, z, 1)
            olePut(objCell,"Value",result)
            z++
        }
    } 
}
oleCloseAutoObject (objExcel)
}
就像我说的,如果到达文件夹的“结尾”,“z”将重置为 1。我能做些什么呢?有什么办法吗?
如果我只是说
print fullName i "\n"
它可以工作......但我需要excel表中的模块名称