通过DXLrecursion列出文件夹中的所有DOORS模块并写入Excel工作表

我希望有人能帮助我:(我之前search过其他问题是否适合…)

我试图用recursion的DXL函数将所有的DOORS模块列在一个特定的目录中,并将模块名称(完整path/名称)写入Excel工作表

这是我到现在为止…问题似乎是“Z”被重置为1了

在Excel VBA中,我调用这样的DXL脚本(工作):

objDoorsApp.runStr ("#include <" & sInterface & ">;;createFolderNameForRecursion ()") 

它调用函数来初始调用recursion函数:(工作也是)

 void createFolderNameForRecursion() { int z = 1 WriteAllModulesRecursively2ExistExcel(folder("/00_Platform/30Software/30_Basis_SW/IoStck"), z); } 

这是recursion函数:

 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表中的模块名称

我会尝试移动你的函数之外的int z = 1 。 如果它在脚本的外层,它将是全局的。 你不需要把它传递给函数,它不应该被重置。

例:

 int z = 1 void WriteAllModulesRecursively2ExistExcel(Folder f) { // do something z++ } void createFolderNameForRecursion() { WriteAllModulesRecursively2ExistExcel(YOUR_FOLDER) } 

祝你好运!